Correct syntax conditional comment?

Discussion in 'HTML' started by andrew, Dec 3, 2007.

  1. andrew

    andrew Guest

    I have been using the following for some time to call a small css for
    anybody still using ie5:

    <!--[if IE 5]>
    <link rel="stylesheet" type="text/css" href="ie5.css" />
    <![endif]-->

    And I have seen countless examples of this exact syntax scattered
    around the web. But I am using 4.01 strict so shouldn't I be using:

    <!--[if IE 5]>
    <link rel="stylesheet" type="text/css" href="ie5.css">
    <![endif]--> ^^

    instead? I suspect not as I have /never/ seen it done this way but I am
    curious about the reason.

    Andrew
    --
    "For the God who sings"
    http://www.andrews-corner.org/ftgws.html
    andrew, Dec 3, 2007
    #1
    1. Advertising

  2. andrew wrote:
    > I have been using the following for some time to call a small css for
    > anybody still using ie5:
    >
    > <!--[if IE 5]>
    > <link rel="stylesheet" type="text/css" href="ie5.css" />
    > <![endif]-->
    >
    > And I have seen countless examples of this exact syntax scattered
    > around the web. But I am using 4.01 strict so shouldn't I be using:
    >
    > <!--[if IE 5]>
    > <link rel="stylesheet" type="text/css" href="ie5.css">
    > <![endif]--> ^^
    >
    > instead? I suspect not as I have /never/ seen it done this way but I am
    > curious about the reason.


    Whether or not there's a trailing slash has nothing to do with the
    conditional comments. If your page is XHTML, you need the trailing
    slash. If it's plain HTML, it shouldn't be there, and if it is, browsers
    may still handle your page but beware of lots of issues that have been
    discussed here many, many times before.
    Harlan Messinger, Dec 3, 2007
    #2
    1. Advertising

  3. andrew

    Dylan Parry Guest

    Harlan Messinger wrote:

    > Whether or not there's a trailing slash has nothing to do with the
    > conditional comments. If your page is XHTML, you need the trailing
    > slash.


    No you don't. It's a comment, so anything within it is simply text as
    far as any non-IE browser or parser is concerned, so it makes no
    difference whether you use the slash or not.

    One could in fact argue that the slash should *never* be used, as the
    code within the comment is *only* interpreted by Internet Explorer, and
    as IE doesn't support XHTML it makes little sense to include thu
    trailing slash in IE-specific code that is actually treated as comment
    text by anything else.

    --
    Dylan Parry
    http://electricfreedom.org | http://webpageworkshop.co.uk

    The opinions stated above are not necessarily representative of
    those of my cats. All opinions expressed are entirely your own.
    Dylan Parry, Dec 3, 2007
    #3
  4. andrew

    dorayme Guest

    In article <>,
    Dylan Parry <> wrote:

    > Harlan Messinger wrote:
    >
    > > Whether or not there's a trailing slash has nothing to do with the
    > > conditional comments. If your page is XHTML, you need the trailing
    > > slash.

    >
    > No you don't. It's a comment, so anything within it is simply text as
    > far as any non-IE browser or parser is concerned, so it makes no
    > difference whether you use the slash or not.
    >
    > One could in fact argue that the slash should *never* be used, as the
    > code within the comment is *only* interpreted by Internet Explorer, and
    > as IE doesn't support XHTML it makes little sense to include thu
    > trailing slash in IE-specific code that is actually treated as comment
    > text by anything else.


    And just in case both answers (by Harlan and Dylan) are not clear
    enough, it is simple enough if you think what the conditional is
    doing.

    Nothing inside the conditional comments is visible to any but IE.
    So that settles one question, namely it does not matter what is
    there for browsers other than IE, never mind a trailing slash,
    you could have a croaking frog in there and they would not know.
    And now the question about what you want IE 5 to see. Well, that
    is really simple too. What do you want it to see? You would not
    want it to see a trailing slash surely, that is not how it is
    done in 4.01. not even for IE5!

    --
    dorayme
    dorayme, Dec 3, 2007
    #4
  5. dorayme wrote:

    > Nothing inside the conditional comments is visible to any but IE.


    Can you provide evidence?
    There are hundreds of high and low quality HTML browsers. I doubt that IE
    5 is the only to have a buggy comment parser that make it think that
    <!--[if IE 5]> is a complete comment.
    --
    If you've a question that doesn't belong to Usenet, contact me at
    <tabkanDELETETHISnaz at yahoDELETETHATo.fr>
    André Gillibert, Dec 3, 2007
    #5
  6. andrew

    dorayme Guest

    In article <op.t2r4ecf47pu1mk@andre>,
    "André Gillibert" <>
    wrote:

    > dorayme wrote:
    >
    > > Nothing inside the conditional comments is visible to any but IE.

    >
    > Can you provide evidence?


    > There are hundreds of high and low quality HTML browsers. I doubt that IE
    > 5 is the only to have a buggy comment parser that make it think that
    > <!--[if IE 5]> is a complete comment.


    If there are other browsers, as likely to be used as IE 5, that
    can read and either suffer some bad consequence or use the
    stylesheet mentioned in OP's original, then perhaps positive
    evidence for this would be more to the point.

    --
    dorayme
    dorayme, Dec 3, 2007
    #6
  7. andrew

    andrew Guest

    On 2007-12-03, dorayme <> wrote:

    [...]

    > And just in case both answers (by Harlan and Dylan) are not clear
    > enough, it is simple enough if you think what the conditional is
    > doing.


    In fact the problem was that rather than making an effort to fully
    /understand/ what I was doing I blindly pasted code with little
    understanding. It validated of course because the validator could not
    see it.

    > Nothing inside the conditional comments is visible to any but IE.
    > So that settles one question, namely it does not matter what is
    > there for browsers other than IE, never mind a trailing slash,
    > you could have a croaking frog in there and they would not know.
    > And now the question about what you want IE 5 to see. Well, that
    > is really simple too. What do you want it to see? You would not
    > want it to see a trailing slash surely, that is not how it is
    > done in 4.01. not even for IE5!


    Thanks for expressing this so clearly. I am in the middle of stripping
    the slash from my hobby site as we speak and cursing myself for not
    /thinking/ about what I was doing.

    Andrew
    --
    "For the God who sings"
    http://www.andrews-corner.org/ftgws.html
    andrew, Dec 3, 2007
    #7
  8. andrew

    dorayme Guest

    In article <>,
    andrew <> wrote:

    > On 2007-12-03, dorayme <> wrote:


    > Thanks for expressing this so clearly. I am in the middle of stripping
    > the slash from my hobby site as we speak and cursing myself for not
    > /thinking/ about what I was doing.
    >


    Don't curse yourself. It is useful to ask people every kind of
    question, including ones you could answer yourself with some
    effort. It avoids having to so often deal with self; this latter
    can get a bit depressing and causes a dampening of the motivation
    to help oneself. People sometimes react badly to some questions
    because they (including myself sometimes) do not have the correct
    human social model in mind.

    In other words, Andrew, do not take to chemical mood lifters,
    come on here anytime... <g>

    --
    dorayme
    dorayme, Dec 4, 2007
    #8
  9. andrew

    Bone Ur Guest

    Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 00:05:58 GMT
    dorayme scribed:

    >> Thanks for expressing this so clearly. I am in the middle of stripping
    >> the slash from my hobby site as we speak and cursing myself for not
    >> /thinking/ about what I was doing.
    >>

    >
    > Don't curse yourself. It is useful to ask people every kind of
    > question, including ones you could answer yourself with some
    > effort. It avoids having to so often deal with self; this latter
    > can get a bit depressing and causes a dampening of the motivation
    > to help oneself.


    People who talk to themselves are nut cases

    > People sometimes react badly to some questions
    > because they (including myself sometimes) do not have the correct
    > human social model in mind.


    Yes, I always check with my social model before I react badly.

    > In other words, Andrew, do not take to chemical mood lifters,
    > come on here anytime... <g>


    True. It's more psychedelic, anyway.

    --
    Bone Ur
    Cavemen have formidable pheromones.
    Bone Ur, Dec 4, 2007
    #9
  10. Dylan Parry wrote:
    > Harlan Messinger wrote:
    >
    >> Whether or not there's a trailing slash has nothing to do with the
    >> conditional comments. If your page is XHTML, you need the trailing
    >> slash.

    >
    > No you don't. It's a comment, so anything within it is simply text as
    > far as any non-IE browser or parser is concerned, so it makes no
    > difference whether you use the slash or not.
    >
    > One could in fact argue that the slash should *never* be used, as the
    > code within the comment is *only* interpreted by Internet Explorer, and
    > as IE doesn't support XHTML it makes little sense to include thu
    > trailing slash in IE-specific code that is actually treated as comment
    > text by anything else.


    Good point. However, if one is making any pretense at having an XHTML
    page, there should be a slash or else one should give up the pretense.
    Harlan Messinger, Dec 4, 2007
    #10
  11. andrew

    dorayme Guest

    In article <Xns99FBC22D85389boneurhyphe@85.214.90.236>,
    Bone Ur <> wrote:

    > People who talk to themselves are nut cases


    So stop doing it already.

    -------------------
    * Harrison Ford admitted to doing it in Firewall (a terrible
    film).

    --
    dorayme
    dorayme, Dec 4, 2007
    #11
  12. andrew

    Bone Ur Guest

    Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 07:20:04 GMT
    dorayme scribed:

    > In article <Xns99FBC22D85389boneurhyphe@85.214.90.236>,
    > Bone Ur <> wrote:
    >
    >> People who talk to themselves are nut cases

    >
    > So stop doing it already.


    Hehe, okay. (Sometimes I even get sick of myself myself.)

    > -------------------
    > * Harrison Ford admitted to doing it in Firewall (a terrible
    > film).


    Never even _heard of_ that film! I'll be sure to remain oblivious to it if
    I can.

    --
    Bone Ur
    Cavemen have formidable pheromones.
    Bone Ur, Dec 4, 2007
    #12
  13. andrew

    dorayme Guest

    In article <Xns99FC132013ECAboneurhyphe@85.214.90.236>,
    Bone Ur <> wrote:

    > > * Harrison Ford admitted to doing it in Firewall (a terrible
    > > film).

    >
    > Never even _heard of_ that film! I'll be sure to remain oblivious to it if
    > I can.


    It is general rule that if keen film buffs have not heard of a
    film, it is probably not very good. But I have come across *many*
    exceptions to this.

    --
    dorayme
    dorayme, Dec 4, 2007
    #13
  14. Harlan Messinger wrote:

    > Good point. However, if one is making any pretense at having an XHTML
    > page, there should be a slash or else one should give up the pretense.


    No conforming XML parser should attempt to parse the contents of a comment
    though, so I don't see why you should add a slash. You're just wasting a
    byte.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 9 days, 16:15.]

    Sharing Music with Apple iTunes
    http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/
    Toby A Inkster, Dec 4, 2007
    #14
  15. Toby A Inkster wrote:
    > Harlan Messinger wrote:
    >
    >> Good point. However, if one is making any pretense at having an XHTML
    >> page, there should be a slash or else one should give up the pretense.

    >
    > No conforming XML parser should attempt to parse the contents of a comment
    > though, so I don't see why you should add a slash. You're just wasting a
    > byte.


    I repeat: "if one is making any pretense at having an XHTML page".
    Harlan Messinger, Dec 4, 2007
    #15
  16. andrew

    Dylan Parry Guest

    Harlan Messinger wrote:

    > I repeat: "if one is making any pretense at having an XHTML page".


    If it helps you, by all means continue to use a slash, but as it's an
    element that has been commented out, it really doesn't matter as
    parsers* won't even see it as being an element. It isn't part of the
    XHTML content of the document - it's nothing more than a comment.

    ____
    * With the exception of IE, of course.

    --
    Dylan Parry
    http://electricfreedom.org | http://webpageworkshop.co.uk

    The opinions stated above are not necessarily representative of
    those of my cats. All opinions expressed are entirely your own.
    Dylan Parry, Dec 4, 2007
    #16
  17. andrew

    Bone Ur Guest

    Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 09:23:02
    GMT dorayme scribed:

    >> > * Harrison Ford admitted to doing it in Firewall (a terrible
    >> > film).

    >>
    >> Never even _heard of_ that film! I'll be sure to remain oblivious to
    >> it if I can.

    >
    > It is general rule that if keen film buffs have not heard of a
    > film, it is probably not very good. But I have come across *many*
    > exceptions to this.


    And in a similar way, I've perused many much-touted films that if they
    weren't outright dogs at least attained no higher than mediocre status.
    Of course even a mediocre film can be entertaining under the right
    circumstances or, perhaps, on a Saturday afternoon couch-potato day,
    preclude the need for a sleep capsule.

    --
    Bone Ur
    Cavemen have formidable pheromones.
    Bone Ur, Dec 4, 2007
    #17
  18. andrew

    Andy Dingley Guest

    On 3 Dec, 21:52, "André Gillibert"
    <> wrote:
    > dorayme wrote:
    > > Nothing inside the conditional comments is visible to any but IE.

    >
    > Can you provide evidence?


    No evidence to hand, but we can provide a proof:

    * These are comments according to the spec

    * A "user agent" is that which correctly implements the spec.

    * "Browsers" are either a form of user agent, or a M$oft product
    that's a browser because they tell you it is.

    * M$oft claim that IE is a browser

    * Therefore all browsers either ignore the contents of these, or they
    are IE.

    * Therefore anything showing these comments is either IE, or it isn't
    a browser
    (for instance, a source editor).
    Andy Dingley, Dec 4, 2007
    #18
  19. Dylan Parry wrote:
    > Harlan Messinger wrote:
    >
    >> I repeat: "if one is making any pretense at having an XHTML page".

    >
    > If it helps you, by all means continue to use a slash, but as it's an
    > element that has been commented out, it really doesn't matter as
    > parsers* won't even see it as being an element. It isn't part of the
    > XHTML content of the document - it's nothing more than a comment.


    I understand perfectly well why it makes no difference in the actual
    validity of the page. I repeat "if one is making any pretense at having
    an XHTML page". Does no one here understand the conditional mood or the
    concept of pretense?
    Harlan Messinger, Dec 4, 2007
    #19
  20. andrew

    Bone Ur Guest

    Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 12:43:28 GMT
    Harlan Messinger scribed:

    >>> I repeat: "if one is making any pretense at having an XHTML page".

    >>
    >> If it helps you, by all means continue to use a slash, but as it's an
    >> element that has been commented out, it really doesn't matter as
    >> parsers* won't even see it as being an element. It isn't part of the
    >> XHTML content of the document - it's nothing more than a comment.

    >
    > I understand perfectly well why it makes no difference in the actual
    > validity of the page. I repeat "if one is making any pretense at having
    > an XHTML page". Does no one here understand the conditional mood or the
    > concept of pretense?


    If not, a brief exchange with my significant other will set you straight in
    no time.

    --
    Bone Ur
    Cavemen have formidable pheromones.
    Bone Ur, Dec 4, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alec S.
    Replies:
    10
    Views:
    10,091
    Alec S.
    Apr 16, 2005
  2. patrick j
    Replies:
    6
    Views:
    396
    patrick j
    Oct 25, 2006
  3. KiwiBrian

    Conditional Comment Query

    KiwiBrian, Oct 26, 2007, in forum: HTML
    Replies:
    3
    Views:
    507
    BootNic
    Oct 26, 2007
  4. John
    Replies:
    2
    Views:
    415
  5. David Combs
    Replies:
    0
    Views:
    184
    David Combs
    Apr 4, 2006
Loading...

Share This Page