- From: Andrew Clover <and@doxdesk.com>
- Date: Mon, 29 Apr 2002 02:04:47 +0000
- To: www-html@w3.org
Jimmy Cerra <jimbofc@yahoo.com> wrote:
> I'm not sure, but would this work????
> <?xml version="1.0">
> <script>
> <!-- <![ CDATA [
> /* some code with double dashes (--'s) */
> // ]]> -->
No. You can't declare a CDATA section inside a comment. You don't
want to put a comment in a <script> block in XHTML anyway - an XML
parser will ignore the lot.
If your aim is to embed non-XML code in an XHTML document such
that it will be compatible with HTML-3.2+ parsers as well as XML
parsers, you will need to write:
<script type="text/javascript">//<![CDATA[[
...
//]]></script>
<style type="text/css">/*<![CDATA[[*/
...
/*]]>*/</style>
If you also need commenting to hide the embedded content from pre-
HTML-3.2 tagsoup browsers, you will need the amusing hacks:
<script type="text/javascript"><!--//--><![CDATA[//><!--
...
//--><!]]></script>
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
...
/*]]>*/--></style>
This is just a reminder that embedding is bad news and linking
will cause far less pain.
--
Andrew Clover
mailto:and@doxdesk.com
http://and.doxdesk.com/
Received on Sunday, 28 April 2002 22:08:10 UTC