On Aug 1, 2005, at 7:51 PM, Matthew Ohlman wrote:
Jon Trelfa wrote:
I didn't have the <[cdata[ ... ]] around my style element
Ummm....I don't think that's necessary, is it? I never use that an my
documents validate just fine...?
Correct me if I'm wrong, but I think It's optional. That does the
equivalent of what <!-- does in Java script--hides the content from
older browsers that do not support CSS.
Actually no, that's not what it does! :-)
The contents of a CDATA section are declared to have no XML
metacharacters. So for instance, you can just write '<' instead of
'<' inside a CDATA section, or '&' instead of '&'.
That's it. It has nothing to do with hiding anything from older
browsers. It's just XML syntactic sugar for not having to escape
certain character entities. (At any rate, note that if you're serving
XHTML, then you don't care about older, pre-CSS browsers, right?)
_However— ... I can't think offhand of any CSS syntax that would
normally include XML metacharacters that require escaping. There's the
child selector '>', but that doesn't have to be escaped. So you're
right, it probably _isn't_ necessary to escape <style> contents in
XHTML.
Javascript in a <script> element is another story, though. There
you'll routinely find '&' and '<', and those do need to be escaped.
But again, it has nothing to do with hiding the Javascript from
incapable browsers — if you care about that, then you still need to
enclose it in comments, even if you have <[cdata[...]]> around it.
Best regards,
—ml—
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/