Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Correct syntax conditional comment?

Reply
Thread Tools

Correct syntax conditional comment?

 
 
andrew
Guest
Posts: n/a
 
      12-03-2007
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
 
Reply With Quote
 
 
 
 
Harlan Messinger
Guest
Posts: n/a
 
      12-03-2007
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.
 
Reply With Quote
 
 
 
 
Dylan Parry
Guest
Posts: n/a
 
      12-03-2007
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.
 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      12-03-2007
In article <(E-Mail Removed)>,
Dylan Parry <(E-Mail Removed)> 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
 
Reply With Quote
 
André Gillibert
Guest
Posts: n/a
 
      12-03-2007
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>
 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      12-03-2007
In article <op.t2r4ecf47pu1mk@andre>,
"André Gillibert" <(E-Mail Removed)>
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
 
Reply With Quote
 
andrew
Guest
Posts: n/a
 
      12-03-2007
On 2007-12-03, dorayme <(E-Mail Removed)> 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
 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      12-04-2007
In article <(E-Mail Removed)>,
andrew <(E-Mail Removed)> wrote:

> On 2007-12-03, dorayme <(E-Mail Removed)> 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
 
Reply With Quote
 
Bone Ur
Guest
Posts: n/a
 
      12-04-2007
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.
 
Reply With Quote
 
Harlan Messinger
Guest
Posts: n/a
 
      12-04-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python syntax for conditional is unfortunate Neal Becker Python 14 09-25-2008 03:16 AM
Conditional modifier syntax Pau Garcia i Quiles Ruby 2 10-23-2006 12:11 AM
Inverted syntax for an if conditional Mark Hobley Perl 7 04-22-2006 11:02 PM
? ELSE Conditional Comment / Using Conditional Comments Inside Other Tags To Comment Out Attributes Alec S. HTML 10 04-16-2005 02:21 AM
need help on a syntax in conditional operator Bill Davidson C++ 2 04-21-2004 07:44 PM



Advertisments