PDA

View Full Version : page validation help needed pls



celicasaur
March 3rd, 2009, 08:21 AM
I'm trying to validate my page but I'm getting the following error:


document type does not allow element "a" here.
menu2[0]='<a href="webservices.htm">web design</a>'✉ (http://validator.w3.org/feedback.html?uri=http%3A%2F%2Fwww.vibrantwebdesig n.co.uk%2Findex.htm;errmsg_id=64#errormsg)
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).


I'm really confused because this looks just fine to me, like I havn't added or not included anything that shouldn't be there. Can anybody help please?

simplistik
March 3rd, 2009, 09:28 AM
you need to show us the page or the html w/ the code in it

celicasaur
March 3rd, 2009, 11:02 AM
<head>

<script type="text/javascript">
//Contents for menu 2

var menu2=new Array()
menu2[0]='<a href="webservices.htm">web design</a>'
menu2[1]='<a href="logoservices.htm">logo design</a>'
menu2[2]='<a href="stationaryservices.htm">stationary</a>'

</script>
</head>

That's pretty much the gyst of it....is that ok?

simplistik
March 3rd, 2009, 04:36 PM
var menu2=new Array();

you're missing a semi-colon after Array(); as a matter of fact you need to close out ALL your lines w/ a semi-colon

celicasaur
March 3rd, 2009, 05:03 PM
Hmmm, spooky. I tried a semi colon in place of the inverted comma and a few other combinations but the error report didn't change on the validator website.


var menu2=new Array();
menu2[0]='<a href="webservices.htm">web design</a>;

I tried semi-colons like above, but it made no difference...any other suggestions?

Templarian
March 3rd, 2009, 07:55 PM
<head>

<script type="text/javascript">
/* <![CDATA[ */
//Contents for menu 2

var menu2=new Array();
menu2[0]='<a href="webservices.htm">web design</a>';
menu2[1]='<a href="logoservices.htm">logo design</a>';
menu2[2]='<a href="stationaryservices.htm">stationary</a>';
/* ]]> */
</script>
</head>
The XHTML standard validates everything basically like xml, so cdata it. Your best to use JS files to hold your JavaScript.

celicasaur
March 3rd, 2009, 08:48 PM
wow, I did what you showed above and it went from 58 errors and 21 warnings to just 14 errors :D

thankyou for your help, sir :)

let's hope i can manage the rest by myself :stare:

thedaveyb
March 4th, 2009, 04:28 AM
I have found that with a lot of online validators, it appears a page has 140 errors but once you actually sort the first or 2nd you will see the rest are a knock on effect of the way the online validator is parsing the page.... hence the number drops dramatically...