Correct syntax conditional comment?

A

andrew

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
 
H

Harlan Messinger

andrew said:
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.
 
D

Dylan Parry

Harlan said:
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.
 
D

dorayme

Dylan Parry said:
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!
 
A

André Gillibert

dorayme said:
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.
 
D

dorayme

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.
 
A

andrew

[...]
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
 
D

dorayme

andrew said:
On 2007-12-03, dorayme <[email protected]> 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>
 
B

Bone Ur

Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 00:05:58 GMT
dorayme scribed:
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.
 
H

Harlan Messinger

Dylan said:
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.
 
B

Bone Ur

Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 07:20:04 GMT
dorayme scribed:
So stop doing it already.

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

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

dorayme

* 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.[/QUOTE]

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.
 
T

Toby A Inkster

Harlan said:
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/
 
H

Harlan Messinger

Toby said:
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".
 
D

Dylan Parry

Harlan said:
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.
 
B

Bone Ur

Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 09:23:02
GMT dorayme scribed:
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.
 
A

Andy Dingley

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).
 
H

Harlan Messinger

Dylan said:
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?
 
B

Bone Ur

Well bust mah britches and call me cheeky, on Tue, 04 Dec 2007 12:43:28 GMT
Harlan Messinger scribed:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top