...

View Full Version : w3 validator help :(



Inxie
02-08-2012, 02:13 AM
I have posted this in HTML and CSS forum but I realise some of this is relevant here.

Hi, I used http://validator.w3.org/ on my new site and it came back with over 40 errors which I tried my very best to fix what I understood but some of it is beyond me.

It still returns 26 errors, my site is www.pagefrog.net

I realise it explains how to fix it but it's still not clear to me sorry :(
all help appreciated. Thanks.

Dormilich
02-08-2012, 07:46 AM
the problem is that you validate as XHTML and display the page as HTML. (note: XHTML would quit on the first error).

if you revalidate as HTML (4.01 Strict) you're left (besides the warnings about the self-closing tags, which are illegal in HTML 4) with deprecated elements and attributes (and one superfluous end tag).

VIPStephan
02-08-2012, 12:10 PM
These errors in the JavaScript come up because you didn’t declare your JS in the XHTML document as character data (http://en.wikipedia.org/wiki/CDATA) (CDATA). The XHTML parser thinks it is part of the HTML and tries to parse it but in HTML all ampersands and “less than” and “greater than” characters must be encoded with appropriate entities.

You declare your JS as character data like this:


<script type="text/javascript">
// <![CDATA[
… JS code here …
// ]]>
</script>


Do that and then validate again.

Dormilich
02-08-2012, 12:19 PM
the JavaScript text issue can be best dealt with by moving the script to an external script file. this way it is not considered by the (X)HTML parser.

felgall
02-08-2012, 07:22 PM
You declare your JS as character data like this:


<script type="text/javascript">
// <![CDATA[
… JS code here …
// ]]>
</script>



If the page is using XHTML then the // on the front of those lines shouldn't be there. If the page is using HTML then those entire lines shouldn't be there. That particular combination only works if the page is HTML being fed into the XHTML validator.

The simplest solution is to keep all the JavaScript in separate files and don't jumble it into the HTML at all.

Inxie
02-09-2012, 01:38 AM
Thank you so much worked a treat. 24/26 fixed!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum