Discussion:
Comments confuse IE 7
(too old to reply)
Andreas Prilop
2007-10-12 14:11:48 UTC
Permalink
Internet Explorer 7 finally supports CSS2 syntax such as
span+span .
However, IE 7 does not apply this selector when <span> and
<span> are separated by a comment. For example,

span { color: blue }
span+span { color: red }

<span>blue</span> <!-- --> <span>red</span>

Then Internet Explorer 7 displays everything in blue.
Test page:
http://www.unics.uni-hannover.de/nhtcapri/temp/morestyles.html
Jukka K. Korpela
2007-10-12 18:38:49 UTC
Permalink
Post by Andreas Prilop
Internet Explorer 7 finally supports CSS2 syntax such as
span+span .
In "standards" mode, yes.
Post by Andreas Prilop
However, IE 7 does not apply this selector when <span> and
<span> are separated by a comment.
A quick guess: it internally treats a comment as an element. Perhaps it
converts it to a <comment>...</comment> "element", a nonstandard construct
recognized by IE only.
Post by Andreas Prilop
For example,
span { color: blue }
span+span { color: red }
<span>blue</span> <!-- --> <span>red</span>
Then Internet Explorer 7 displays everything in blue.
Assuming it treats <!-- --> as an element (quite incorrectly, of course), we
can expect it to treat the second span as not matching span+span.

I think my hypothesis is confirmed by the observation that if I set

span:first-child { color: red;}

and use

<p><span>foo</span></p>
<p><!-- --><span>foo</span></p>

then the first foo appears in red, the second one does not.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Loading...