Re: <![CDATA[ ... ]]> and HTML Elements

Fergal Daly <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
On Tue, Nov 09, 2004 at 10:20:09AM +0000, Chris Croome wrote:
> Hi
> 
> On Mon 08-Nov-2004 at 04:13:08PM -0500, William McKee wrote:
> >
> > I'd since stopped using the // <!-- // --> comments since they are
> > mostly unnecessary.
> 
> They are potentially worse than unnecessary if you are producing
> XHTML:
> 
>   C.4. Embedded Style Sheets and Scripts
> 
>   Use external scripts if your script uses < or & or ]]> or --.
>   Note that XML parsers are permitted to silently remove the contents
>   of comments. Therefore, the historical practice of "hiding" scripts
>   and style sheets within "comments" to make the documents backward
>   compatible is likely to not work as expected in XML-based user
>   agents.
> 
>   http://www.w3.org/TR/xhtml1/#C_4

This is in the context of creating XHTML that is compatible with HTML. The
first sentence means that you just can't do it if you have < or & ]]> or --
in an in-page script.

XHTML and HTML have incompatible ways of dealing with script tags and you
need to aim at one or the other (or move your scripts into a .js file).

What are these scripts that can't be put in a .js file anyway?

Fergal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.