SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,761
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Conditional Comment: All Browsers Except IE6 and Lower

    I was wondering if it were possible to have a conditional comment that says show to all browsers, save for anything lower than IE7.

    I tried this, but didn't work: <!--[if !(IE)|(gte IE 7)]>

    Is there a way? I'm trying different patterns and so far can't see anyting show in firefox.

    Cheers
    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,871
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Only Microsoft programs understand those conditional comments so you have to code them so that what you don't want other browsers to see is inside the <!-- --> and what you do want other browsers to see is not inside the comment.
    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
    Non-Member
    Join Date
    Jun 2010
    Location
    4727′35″N 2618′0″E
    Posts
    1,789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand correctly what you're asking, then you can make use of downlevel-revealed conditional comments: http://msdn.microsoft.com/en-us/libr...spx#dlrevealed.

    In fact, I used something like this for the SPF Pure HTML & CSS comp. For IE6 I'm not bothering with fixes or hacks anymore, and since JS is out the door, I just let my beautiful CSS-nude semantic mark up be And it suits me just fine.

    It's time to let go of IE6, IE9 is already taking over big time. And it's time to exploit a better CSS: + selector, :hover for anything, w/o thinking first how can you patch it with JS libraries. I mean, we talk about CSS3 but we still don't see a heavy serious COMPLETE use of decades old CSS 2.1, and we still use JS to patch weak CSS implementations like it's 1997. Basta!

    The page below will have red background for all browsers, except IE1-IE6. My personal COMPLETE graceful degradation for IE6 The CGD movement.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en" dir="ltr"><head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta http-equiv="content-language" content="en">
        <title>Only IE 7 and up. And the rest.</title>
        <meta name="author" content="noonnope - Mitică U.">
        <meta name="copyright" content="noonnope - Mitică U.">
        
    <![if !(lt IE 7)]>
        <style type="text/css">
        
          body {
              background:red;
            }
    
        </style>
    <![endif]>
    
    </head><body>
    
      <h1>If it's red screen then it's not IE1-IE6!</h1>
    
    </body></html>

  4. #4
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,761
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the feedback. I sort of did an ifstatement that just changed the style display of the footer I was trying to have to "none" if IE and less than 7.

    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  5. #5
    Non-Member
    Join Date
    Jun 2010
    Location
    4727′35″N 2618′0″E
    Posts
    1,789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <![if !(lt IE 7)]>
    [...]
    <![endif]>

    means [...] will NOT apply to IE less than IE 7, but it will apply to IE7+ and ALL the other browsers, including Firefox. Isn't that what you wanted?




    So, if you have style you DO NOT want it applied to IE6-, you put

    <![if !(lt IE 7)]>

    <![endif]>

    around it.



    <![if !(lt IE 7)]>

    <![endif]>

    will be recognized only by IE-family browsers: IE6- will not apply the part in between, IE7+ will apply it, and those two lines will be indiferent to the rest of the browsers: FF, Ch, Op, Saf etcetera, as they will apply the part in between, like IE7+, since it's not a comment, the comment feature that is the downside for using the other IE CC: <!--[if ... endif]-->.

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,550
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Unfortunately the Microsoft downlevel revealed comments are invalid and will not pass validation. There is however an alternative that is valid and goes like this:

    Code:
    <!--[if gte IE 7]><!-->
      <p>This is shown in downlevel browsers and IE7 or later.</p>
    <!--<![endif]-->
    More info here.

  7. #7
    Non-Member
    Join Date
    Jun 2010
    Location
    4727′35″N 2618′0″E
    Posts
    1,789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a false positive, so to speak, and it's not an error, strictly speaking, much like -moz, -webkit CSS aren't. And the one I appreciate and tolerate, like <xml> element, that I, once again, feel it should have been a natural solution for many, many problems. I almost love <xml> and feel so sad it's not standard, not even in these new specs.

    I prefer to use less:
    <![if !(lt IE 7)]>

    than more
    <!--[if gte IE 7]><!-->

    which, by the way, is a dirty trick. Maybe clever, but dirty. I don't like this "smartiness" in my code.

    It's for the same reason I don't agree with *+ html, for example, and I prefer a clean CC. I'm not making my omelet mixing rotten eggs with good ones. My unclean code on a side, my clean code on the other side. But it's a personal choice.

  8. #8
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,550
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Yes I only mentioned it for completeness and in case they were needed to validate. It's of little consequence otherwise I agree.


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
  •