XHTML validation with JavaScript

The W3C XHTML validator will complain if you’ve got JavaScript embedded in your XHTML markup and you haven’t taken steps to make it XHTML friendly.

Either move the JavaScript into a file (in this example called script.js):

<script src="script.js" type="text/javascript"></script>

Or add CDATA tags around the JavaScript that’s embedded in the markup:

<script type="text/javascript">
<![CDATA[
... unescaped script content ...
]]>
</script>

References

Last modified: 08/05/2006 (most likely earlier as a site migration in 2006 reset some dates) Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top