Re: Internet Explorer won't hide nested paragraphs
- From: "Andy Dingley" <dingbat@xxxxxxxxxxxxxx>
- Date: 12 Mar 2007 04:53:44 -0700
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.
.
- References:
- Internet Explorer won't hide nested paragraphs
- From: danep
- Internet Explorer won't hide nested paragraphs
- Prev by Date: Re: URI scheme for (geographical) map or address location? To-Do?
- Next by Date: Re: Highlighting a Link Destination
- Previous by thread: Re: Internet Explorer won't hide nested paragraphs
- Index(es):
Relevant Pages
|