Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

conditional comments

do not validate



3:07 pm on Feb 8, 2012 (gmt 0)

5+ Year Member

I recently discovered 'compatibility view' in IE8. Why and how? after 2.5 years of learning (primarily on Firefox) this HTTP stuff? By way of explanation: I sent a former employer my domain and she replied that 'it is kind of jumbled' but admitted that she was stuck with IE6 (a Fortune 500 company!). So, I've spent the past week implementing very limited use of conditional comments, absolutely NO CSS hacks, and I'm not trying to emulate current technologies to work in IE6 simply for appearance sake. I've simply taken into account: absolute positioning, min-width, max-width and setAttribute.

What I've decided is if IE6 cannot render a page as I've built it then I'm not allowing it to invoke the page. So, I started with:

<!-- [if gte IE 8]>
*** allow IE8+ and all other user-agents ***

But what I discovered was that Google Chrome, Opera, FF were also denied. After reviewing conditional comments(CCs) again at[msdn.microsoft.com ] which, to microsofts credit, does give a detailed description, I came to understand that 'down-level hidden' excludes browsers that are mute to CCs; I then tried this:

<![if gte IE 8]>
***allow IE8+ et al ***

...which is 'down-level revealed'; works but will not validate because CCs revealed are not valid HTML. So, my question is, is there a way to implement CCs to do what I want them to do and validate? If not then is there a 'standard' feature detection way that folks use that I'm not aware of?

Here is the actual HTML I'm working with:

<![if gte IE 8]>
<li><a href="js_planets_gallery.shtml" class="textLink">Planets of the Solar System</a>:
<abbr title="HyperText Markup Language">HTML</abbr>,
<abbr title="Cascading Style Sheet">CSS</abbr>,
<abbr title="Document Object Model">DOM</abbr> scripting using JavaScript</li>

Thanks all.


3:35 pm on Feb 8, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

<!--[if gte IE 8]-->
*** allow IE8+ and all other user-agents ***


4:17 pm on Feb 8, 2012 (gmt 0)

5+ Year Member

Yes Fotiman, I tried that before my original posting but thought it was not entirely legal, but even though the other browsers (GC,FF,O) handle those conditional comments as expected, IE8 in compatibility view and not, actually displays the conditional comments and their contents on screen?!? BTW: I'm using Windows XP SP3 using IE8.

Ok, just returned from the MS site again and in the Community Additions of the page a poster posted (3/11/2010) this for just the problem described above:

Fixing Validation Errors

The downlevel-revealed conditional comment syntax is flagged as invalid HTML by some validation services. Additional characters can be added to construct a valid HTML Comment before and after the HTML content to be revealed.

<!--[if !IE]>--> HTML <!--<![endif]-->

In the example above, the negative conditional expression prevents Internet Explorer from displaying the HTML content within the downlevel-revealed conditional comment block. However, if the conditional expression evaluates to true, the closing "-->" of the first comment appears along with the HTML content in Internet Explorer. To hide these characters from Internet Explorer users, add "<!" as follows:

<!--[if !IE]><!--> HTML <!--<![endif]-->

And it works and validates, am happy now. I should have read the Community Additions to the MS page initially.


4:45 pm on Feb 8, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Huh. That's weird.


11:28 pm on Feb 8, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

You don't need the all-encompassing "if IE" do you? MS claims that MSIE 10 will no longer recognize CCs (thread somewhere in these Forums). Conversely, they only came into use with MSIE 5.* So the only thing you need to code for is MSIE in the 5-7 range. Forward compatibility isn't an issue.

* There exist humans who still use MSIE 5, but I have never met a non-robot using anything older. And those MSIE 5 users are on Macs, which apparently never recognized the CC.


11:38 pm on Feb 9, 2012 (gmt 0)

5+ Year Member

lucy24 - thanks for the headsup re ie10. I'm actually planning on removing CCs completely as soon as I replace setAttribute in my DOM examples with the respective HTML-DOM properties.

Featured Threads

Hot Threads This Week

Hot Threads This Month