- From: David Dorward <david@dorward.me.uk>
- Date: Thu, 14 Feb 2008 23:22:31 +0000
- To: www-validator@w3.org
- Message-Id: <F7152E38-8784-4587-85DF-AF470D28B713@dorward.me.uk>
On 14 Feb 2008, at 20:09, Frank Ellermann wrote: > Yes, that is correct, you cannot have other elements in a > script. A HTML trick to get around this could be to put > the content of the script into a comment: > > | <script type="text/javascript"><!-- No. That lets user agents which don't understand <script> elements (like Netscape 1.0) avoid rendering the content of the script element as content. It is pointless on the web of 2008. The script element is defined as containing CDATA in the HTML DTDs, so the comments are treated like the rest of the code within the element - as CDATA, not HTML comments. > | (...) <style type='text/css'> (...) </style> (...) > | //--></script> > > For XHTML it's more convoluted, something like: > > | <script type="text/javascript"><!--//--><![CDATA[//><!-- > | (...) <style type='text/css'> (...) </style> (...) > | //--><!]]></script> And don't do that. Having nothing more then the CDATA markers is enough, as is using > and friends instead of < and co... ... unless you are serving as text/html (making using XHTML in the first place, almost certainly, pointless) in which case the specification tells you to use an external script. -- David Dorward http://dorward.me.uk/ http://blog.dorward.me.uk/
Received on Thursday, 14 February 2008 23:23:04 UTC