Re: Internet Explorer won't hide nested paragraphs



On 11 Mar, 16:12, "danep" <danepow...@xxxxxxxxx> wrote:

On my site I have a section of code that resembles the following:

<p id="gear" style="display: none;">
<p>test</p>
</p>

This renders fine in Firefox (that is, nothing is displayed).
However, in Internet Explorer, "test" is still printed.

I was surprised to see your claim here that FF displays nothing and so
renders this incorrectly. I then tried it out myself (with an
appropriat page header added) and AFAICS, FF is correct and does show
"text".

Of course I should have simply ignored your posting as:
* It discusses complicated rendering behaviour
* It's a posted example, not a live URL
* It's a partial fragment.

Any of these is reason that we need to see exactly what you're seeing,
otherwise we just can't expect to see the same behaviour. Which
doctype did you use? Which doctype declaration? Which content-type?


As to why it does all this, then it's quite simple. However it's an
SGML parsing issue, not an invalid code issue. Although error
correction mechanisms in each browser are (legitimately) potentially
different, they all ought to parse valid SGML correctly even if this
doesn't mean quite what the author intended.

<p> can't nest a <p> inside it, so the start of the 2nd <p> implictly
closes the first one. It's not "nested" and so the display property
obviously isn't (and shouldn't be) inherited.
It's still valid though (there are plenty of valid pages without a
single </p> end tag anywhere near them).

Compare these instead:

<p style="display: none;">
<p>test</p>.

<div style="display: none;">
<p>test (div)</p>
</div>

See the difference? Try looking with the FF DOM Inspector

These are still valid HTML and are sufficient to give the behaviour
that has puzzled you. They're not _invalid_ until we encounter the
second </p>, which is an end tag to an element that has already been
closed.

Browsers may well vary in how they handle this spurious end tag
(another reason to use valid code). However explaining your specific
issue doesn't require invalidity.

.



Relevant Pages

  • Re: Simple 2d graphing in web page - where to begin
    ... a time display of the cursor position as it is moved over the image. ... Java noob question: what /type/ of Java would I need? ... would have a server or servlet application that access the database, ... that renders the graphs. ...
    (comp.lang.java.programmer)
  • Re: *Solved* Why doesnt this page display anything in IE6?
    ... short tag for, and instead requires that the end tag be ... is for these platforms and if this is your only audience then code for those ... renders but scripts broken in Opera ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Master Pages: Why is all of my content centered?
    ... labels I had CSS on weren't using height and width. ... hope Microsoft eventually changes the renders of labels to DIVs ... I did try removing everything from inside the body tag ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: The link button is not showingcorrect
    ... for an anchor (what a link button renders as), you need to set the following ... to control the display ... -- bruce ...
    (microsoft.public.dotnet.framework.aspnet)
  • ASP:image renders empty alt atrribute on some servers
    ... I've created an image control of my own as a decendant of asp:image ... development environment though) this control renders an empty alt attribute ... tag overrides this title tag. ...
    (microsoft.public.dotnet.framework.aspnet)