- From: Shawn Medero <soypunk@gmail.com>
- Date: Wed, 21 Nov 2007 10:44:52 -0500
- To: "Dean Edridge" <dean@55.co.nz>
- Cc: "Anne van Kesteren" <annevk@opera.com>, "Maciej Stachowiak" <mjs@apple.com>, "HTML WG" <public-html@w3.org>
On Nov 21, 2007 10:16 AM, Dean Edridge <dean@55.co.nz> wrote:
> Surely it's not too hard to use:
>
> <script src="js/ufo.js" type="text/javascript"></script>
Ian Hickson covered this topic nicely via http://www.hixie.ch/advocacy/xhtml:
* <script> and <style> elements in XHTML sent as text/html have to be
escaped using ridiculously complicated strings.
This is because in XHTML, <script> and <style> elements are #PCDATA
blocks, not #CDATA blocks, and therefore <!-- and --> really _are_
comments tags, and are not ignored by the XHTML parser. To escape
script in an XHTML document which may be handled as either HTML4 or
XHTML, you have to use:
<script type="text/javascript"><!--//--><![CDATA[//><!--
...
//--><!]]></script>
To embed CSS in an XHTML document which may be handled as either
HTML4 or XHTML, you have to use:
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
...
/*]]>*/--></style>
Yes, it's pretty ridiculous. If documents _aren't_ escaped like
this, then the contents of <script> and <style> elements get
dropped on the floor when parsed as true XHTML.
(This is all assuming you want your pages to work with older
browsers as well as XHTML browsers. If you only care about XHTML
and HTML4 browsers, you can make it a bit simpler.)
Received on Wednesday, 21 November 2007 15:45:06 UTC