SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Mar 2010
    Location
    UK
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parentheses in conditional comments

    Curious. What's the difference between these two conditional comments?

    HTML Code:
    <!--[if gte IE 8 | !IE]><!-->
    
    <!--[if (gte IE 8) | !(IE)]><!-->
    The Sitepoint reference entry lists parentheses as a "subexpression operator". But today I've seen both of the above versions used and on my own site, I use the first version. Is it right/wrong or does it matter?

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,811
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    In that particular case since only IE reads conditional comments in the first place, the !IE is just a comment to remind you that the condition also applies to all other browsers.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Addict
    Join Date
    Mar 2010
    Location
    UK
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but what about the parentheses?

  4. #4
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I know they're not needed if you aren't using the | or in there... but with the OR you'd think it was safer. I'd check the MSDN pages regarding CC's to be sure. It's possible they are necessary when using | and it just looks like it's working because the !IE thing makes no sense... only IE would read the "not IE" comment, so no not-IE browsers will see that.

    <!--[if gte IE 8]> stuff for browsers IE8 and IE9... IE10 does not do CCs<!-->

    I would think the parens would work like this anyway:
    <!--[if (gte IE 8 | IE 6)]> stuff for browsers IE8 and IE9... and IE6 (so, skipping IE7)<!-->

  5. #5
    SitePoint Addict
    Join Date
    Mar 2010
    Location
    UK
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Stomme poes.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •