[whatwg] Common Subset

Lachlan Hunt lachlan.hunt at lachy.id.au
Sat Dec 9 04:50:58 PST 2006

Alexey Feldgendler wrote:
> The HTML5 spec could somehow officially bless CDATA only when used like 
> this:
> <script>//<![CDATA[
> ...
> //]]></script>
> It would not harm because it is already interoperable.

It's technically already allowed because script and style elements are 
defined to contain CDATA.  So basically any string of text that doesn't 
include '</' before the end tag is valid.

It's already interoperable because that whole string is passed to the 
javascript engine, and since the '<![CDATA[' and ']]>' are commented out 
with javascript comments, they're ignored.

For more information, see

> But it seems somehow stupid to define that <![CDATA[ and ]]> are only 
> allowed inside <script> after "//".

There is nothing to define beyond what is already in the spec.  Just 
like <!-- and --> isn't a real comment inside an HTML script element, 
that isn't a real CDATA section.

Only Opera (AFAIK) even implemented support for CDATA sections in HTML. 
  So although that may suggest that they can be supported by browsers 
without breaking anything, their use wouldn't be backwards compatible 
with other legacy browsers, so they have to be forbidden.

Lachlan Hunt

More information about the whatwg mailing list