Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Conditional Comments issues

  1. #1
    Join Date
    Jan 2007
    Location
    Anchorage, Alaska
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Conditional Comments issues

    I have been trying to add a conditional comment to my website so that I can redirect IE 6 and lower to a different stylesheet. I can't seem to get my IE 6.0 browser to recognize that conditional comments. Here is a link to the page: http://tehome.net/trial.html.

    The is the code I used in the head:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/tester2.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Trace Elements</title>
    <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <meta name="" content="Trace Elements : style for your home." />
    <meta name="Keywords" content="trace elements, tehome, tehome.net, tehome.com, anchorage, ak, alaska, home, decor, accessories, accents, interior design, lighting, rugs, furniture, furnishings, candles, modern, decorate, trase elements, design, designer, bedding, contemporary, pillows, dining, entertaining, gifts, gift, " />
    <meta name="Description" content="Home accessories boutique in downtown, Anchorage, Alaska." />
    <link href="stylesheet3.css" rel="stylesheet" type="text/css" />
    <!--[if lte IE 6]>
    <link href=ie-stylesheet.css rel="stylesheet" type="text/css" />
    <![endif]-->
    <style type="text/css">
    <!--
    body {
    background-image: url(images/damask.jpg);
    background-repeat: repeat;
    margin: 0px;
    padding: 0px;
    border-top-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 0px;
    }
    -->
    </style>
    </head>

    Can anyone tell me what I am doing wrong? Thank you!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Hard to know what the issue is, it could be several things or a combination. In order of which I see as most likely:

    1 ) If you are using the eolas (or any other) stand-alone installation of IE 6 on a computer that also has IE 7 installed, IE 6 will think that it is IE 7 when it sees these comments and thus ignore them just like IE 7 would. A real IE 6 browser installed on a computer as its primary Explorer browser will follow the comments as intended.

    2 ) Using an XHTML DOCTYPE throws IE 6 into Quirks mode so, your styles may not work as expected. To test, use a HTML 4.01 strict DOCTYPE and just a plain <html> opening tag.

    3 ) If the styles included on the IE 6 specific stylesheet aren't written correctly in order to produce the desired effect, they won't work anyway, even if IE 6 does look at them. To Test, remove the conditional comments.

    4 ) Styles cascade so with this:

    Code:
    <link href="stylesheet3.css" rel="stylesheet" type="text/css" />
    <!--[if lte IE 6]>
    <link href=ie-stylesheet.css rel="stylesheet" type="text/css" />
    <![endif]-->
    <style type="text/css">
    <!--
    body {
    background-image: url(images/damask.jpg);
    background-repeat: repeat;
    margin: 0px;
    padding: 0px;
    border-top-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 0px;
    }
    -->
    </style>
    The styles in red will override anything in either stylesheet. To Test, get rid of the red stuff.

    5 ) The href attribute should be quoted:

    Code:
    <link href="ie-stylesheet.css" rel="stylesheet" type="text/css" />
    6 ) Poorly constructed META tags may be interfering, to test, temporarily remove them.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <style type="text/css">
    <!--
    Comments in stylesheets are not ignored in XHTML, so that <style> element may as well be blank.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey View Post
    Comments in stylesheets are not ignored in XHTML, so that <style> element may as well be blank.
    Probably not in IE 6.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, since IE doesn't support XHTML at all. The page will be unviewable.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey View Post
    No, since IE doesn't support XHTML at all. The page will be unviewable.
    Huh? I really don't think this is borne out by experience. As I implied before, as far as I know (and I did tests on this at one point) - Even with a server that serves XHTML and a valid XHTML page (or even just one that doesn't break the server's ability to serve it as XHTML), IE 6 will render the page in HTML quirks mode. Generally not a pretty picture for valid XHTML but, a far cry from unviewable, unless you are Monk, or something like that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Even with a server that serves XHTML and a valid XHTML page (or even just one that doesn't break the server's ability to serve it as XHTML), IE 6 will render the page in HTML quirks mode.
    No, it will render it in Quirks if it's sent as text/html. This isn't XHTML, it's invalid HTML (what Mike refers to as pseudo-XHTML), and you're right, those comments will have no effect if it's being rendered as bad HTML.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well I did do an experiment a while back and validated a page as XHTML strict or perhaps transitional. I uploaded it to the server and then established that it was being parsed that way by FF and then found that it rendered in quirks mode in IE 6. I suppose this could have had as much to do with the server recognising IE 6 couldn't parse the XHTML as anything else and serving it as HTML, or perhaps FF parsing it as XHTML even though it was served as HTML.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I suppose this could have had as much to do with the server recognising IE 6 couldn't parse the XHTML
    One of IE's most irritating little idiosyncracies is that it sends Accept: */* with every request, telling the server it can parse anything.
    or perhaps FF parsing it as XHTML even though it was served as HTML.
    Neither. It would have been parsed in Standards mode by Fx, but only after error-correcting to HTML. The resulting DOM tree isn't an XHTML one (as evidenced by the fact that things like innerHTML work with pseudo-XHTML, while they don't when parsing an XHTML document).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK then, FF said it was XHTML, so there you go and if what you say about IE accepting anything is true, it managed to render the page, though poorly.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •