Tuesday, July 23, 2024

Validate JavaScript with HTML tags against XHTML 1.0

You wish to validate your selfcreated Joomla component or template against XHTML 1.0 but the validator mentioned issues inside your JavaScript section in the header. You checked the header and the JavaScript in it and you see that it included some HTML elements (the validator didn´t expect such elements in the header).


<script type="text/javascript">
var messpic = new Array(
"<img id='homepagePic' src='/images/homepage1.jpg' alt='Main Home Page Image' border='0' />",

So the <img> elements caused the issues. The solution is to make your script wrapper look like this (see CDATA section):

<script type="text/javascript">
/* <![CDATA[ */

// content of your Javascript goes here

/* ]]> */

as mentioned here as well.

Related Articles


Please enter your comment!
Please enter your name here

Stay Connected

- Advertisement -

Latest Articles