Tuesday, April 16, 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).

Example:

<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

/* ]]> */
</script>

as mentioned here as well.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

35FollowersFollow
- Advertisement -

Latest Articles