W3C home > Mailing lists > Public > www-html@w3.org > April 2002

Re: Double hyphens ('--') in comments invalid

From: Andrew Clover <and@doxdesk.com>
Date: Mon, 29 Apr 2002 02:04:47 +0000
To: www-html@w3.org
Message-ID: <20020429020447.A24473@doxdesk.com>
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[[

  <style type="text/css">/*<![CDATA[[*/

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[//><!-- 

  <style type="text/css"><!--/*--><![CDATA[/*><!--*/ 

This is just a reminder that embedding is bad news and linking
will cause far less pain.

Andrew Clover
Received on Sunday, 28 April 2002 22:08:10 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:05:59 UTC