Conditional Comments syntax question

Hello amigos,

Edit– Please answer the specific question, this post isn’t about if Conditional Comments are valid, not valid, a thing of the past, which IE versions support it… etc. Thanks.

In the following Conditional Comment, what is does this part <!--> do or mean, or if it’s necessary?

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

I’m used to writing Conditional Comments like this, without the <!--> part:

<!--[if !IE]>

Thanks in advance for any help.

Are not conditional comments pretty much a thing of the past?

AFAIK newer versions of IE don’t recognize them anyway.

They are a thing of the past depending on particular circumstances, we can’t generalize.

You are correct, “newer” versions of IE (since IE10) don’t support them.

But my question is very specific, if you could provide any insight it would be very helpful.


Well, there is this SitePoint article from a little over a year ago.

Unless I’m missing it I don’t see anything like the

``<!–> part`

you are asking about

1 Like

Yes, I saw it.

And now that I’m reading it again, it does mention what the <!--> does:

This example uses valid HTML, but IE7 and later browsers will also reveal the --> after the opening conditional statement. The fix suggested by Microsoft is to add an extra < ! just after the opening conditional comment:

<!--[if gte IE 7]><!-->
  <p>This is shown in downlevel browsers and IE7 or later.</p>

The article calls it Downlevel-revealed Conditional Comments which I did not know the name of.

It’s the last example in that section.

It’s basically putting a Conditional Comment inside an HTML comment so IE7+ browsers don’t reveal the --> after the opening conditional comment… o_O

Thanks for your time! :slight_smile:

1 Like

That part of the code is what actually makes it a comment. They’re HTML Comment Tags.

1 Like

Yep, I just didn’t realize simple HTML comments were being used to encapsulate Conditional Comments.


That’s what hides the IE9- conditional comments from browsers that don’t understand them such as Chrome, Firefox, IE10 etc.

If you didn’t need to hide them from other browsers you could write <![if gte IE 7]> <![endif]>

– inside of conditional comments are ignored by versions of IE that understand the comments so <!--[ gets treated the same as <![ and ]--> gets treated the same as ]>

1 Like

That was originally taken (almost word by word) from the book (and reference) that Tommy and I wrote quite a few years earlier. Glad to see its still useful :smile:


Mr. O’Brien!! Are you promoting yourself!?! How naughty of you :stuck_out_tongue:

When I’m older I’ll write books too. Probably about stupid things but I’ll write them. I don’t know if anyone will read them though :wink:

No, SitePoint :slight_smile:


Or both :wink:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.