XHTML CDATA and comment tags (was: Re: [thelist] different ways of importing css + tip)

Ben Dyer ben_dyer at imaginuity.com
Wed Nov 13 13:01:00 CST 2002


At 12:37 PM 11/13/2002, Bill Mason wrote:
>At 10:05 AM 11/13/2002, Ben Dyer wrote:
>>You can use both properly by doing the following:
>>
>><script language="JavaScript" type="text/javascript">
>><!-- <![CDATA[
>>    // Whatever.
>>// ]]> -->
>></script>
>
>That may *work* in current browsers, but I would hardly call it proper. If
>you serve XHTML as an XML mime type, a correct XML user agent will obey the
>comment tags and ignore the entire script.

However, if you are trying to validate XHTML 1.0 Transitional and want to
support older browsers, that is still the only "proper" way to do both.

But, if you're pushing actual XML, you're not supporting older browsers
anyways because they won't be able to view a true XML document properly
anyway, making the *need* for the comment trick a moot point.

Everyone's situation varies...knowing is half the battle, etc., etc.

--Ben




More information about the thelist mailing list