Discussion:
Conditional comments displayed on page
(too old to reply)
Chris Beall
2009-11-23 22:39:39 UTC
Permalink
URL: http://ulsterliteracy.org/sandbox/

Conditional comments are used to expose unique HTML for IE 7 and below.
As expected, non-IE browsers correctly ignore the conditional comments.
IE6, IE7, and IE8 all DISPLAY the conditional comments on the page (and
also all select the code bracketed by [if IE lte 7]).

I've looked at this over and over and can't see what is wrong.

I need another pair of eyes to look at the source and tell me where I've
gone wrong. My reference for the coding was
http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx

Chris Beall
PA Bear [MS MVP]
2009-11-23 23:17:20 UTC
Permalink
See
http://validator.w3.org/check?uri=http%3A%2F%2Fulsterliteracy.org%2Fsandbox%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
Post by Chris Beall
URL: http://ulsterliteracy.org/sandbox/
Conditional comments are used to expose unique HTML for IE 7 and below.
As expected, non-IE browsers correctly ignore the conditional comments.
IE6, IE7, and IE8 all DISPLAY the conditional comments on the page (and
also all select the code bracketed by [if IE lte 7]).
I've looked at this over and over and can't see what is wrong.
I need another pair of eyes to look at the source and tell me where I've
gone wrong. My reference for the coding was
http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx
Chris Beall
Chris Beall
2009-11-24 00:13:30 UTC
Permalink
Um, yes I do see it. 8 errors, one for each conditional statement.
Actually I saw it before posting here. The validator doesn't like the
conditional comment syntax. I can't fix that.

But looking at it again (after a good dinner), I notice that the correct
syntax is:
<![if gt IE 7]>
whereas I consistently tried to make it a comparison between IE and the
version number:
<![if IE gt 7]>
which is wrong. Apparently when IE hits this, it detects the bad syntax
and, unable to act upon the condition, displays it instead.

So I fixed that and now it works fine.

Oh, and still gets 8 validation errors...

Cheers,
Chris Beall
Post by PA Bear [MS MVP]
See
http://validator.w3.org/check?uri=http%3A%2F%2Fulsterliteracy.org%2Fsandbox%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
Post by Chris Beall
URL: http://ulsterliteracy.org/sandbox/
Conditional comments are used to expose unique HTML for IE 7 and below.
As expected, non-IE browsers correctly ignore the conditional comments.
IE6, IE7, and IE8 all DISPLAY the conditional comments on the page (and
also all select the code bracketed by [if IE lte 7]).
I've looked at this over and over and can't see what is wrong.
I need another pair of eyes to look at the source and tell me where I've
gone wrong. My reference for the coding was
http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx
Chris Beall
Chris Beall
2009-11-25 19:52:47 UTC
Permalink
The bracketed code is intended for IE8 (and above) and all non-IE
browsers. If I did what you suggest, non-IE browsers would see the
whole thing as a comment.

The syntax I used validates and seems to work everywhere I've tested.

Again, the original problem was the syntax WITHIN the CC; I had 'if IE
gt 7'.

Chris Beall
Hi Chris,
Change this
<!--[if gt IE 7]><!-->
<div class="header">
<div class="logo">
<!--<![endif]-->
to
<!--[if gt IE 7]>
<div class="header">
<div class="logo">
<![endif]-->
Comment: The IE Conditional comments don't like nested comment tags.
Usually you use conditional comments in the head section to call in a
different stylesheet.
Post by Chris Beall
URL: http://ulsterliteracy.org/sandbox/
Conditional comments are used to expose unique HTML for IE 7 and below.
As expected, non-IE browsers correctly ignore the conditional comments.
IE6, IE7, and IE8 all DISPLAY the conditional comments on the page
(and also all select the code bracketed by [if IE lte 7]).
I've looked at this over and over and can't see what is wrong.
I need another pair of eyes to look at the source and tell me where
I've gone wrong. My reference for the coding was
http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx
Chris Beall
rob^_^
2009-11-25 18:46:16 UTC
Permalink
Hi Chris,

Change this

<!--[if gt IE 7]><!-->
<div class="header">
<div class="logo">
<!--<![endif]-->
to
<!--[if gt IE 7]>
<div class="header">
<div class="logo">
<![endif]-->


Comment: The IE Conditional comments don't like nested comment tags. Usually
you use conditional comments in the head section to call in a different
stylesheet.
Post by Chris Beall
URL: http://ulsterliteracy.org/sandbox/
Conditional comments are used to expose unique HTML for IE 7 and below.
As expected, non-IE browsers correctly ignore the conditional comments.
IE6, IE7, and IE8 all DISPLAY the conditional comments on the page (and
also all select the code bracketed by [if IE lte 7]).
I've looked at this over and over and can't see what is wrong.
I need another pair of eyes to look at the source and tell me where I've
gone wrong. My reference for the coding was
http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx
Chris Beall
Loading...