Forum Moderators: open

Message Too Old, No Replies

Validation error I don't understand?

"Does not allow element ... here"

         

Warboss Alex

11:22 am on Aug 18, 2004 (gmt 0)

10+ Year Member



Hey everyone,

I'm getting some odd errors from the w3c html validator I don't understand. Specifically, it's telling me that my <head> tag isn't open when it is, I'm not allowed such and such element here.. etc.

I'm assuming that because it can't find the beginning of the <head> tag, it's giving me all the other messages. HTML and errors follow:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Home</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="imagetoolbar" content="no" />

<script type="text/javascript" src="includes/scripts/common.js"></script>
<style type="text/css" media="all">@import "includes/css/default.css";</style>

</head>

<body>
//the page
</body></html>

The associated errors are:

document type does not allow element "META" here
document type does not allow element "STYLE" here
end tag for element "HEAD" which is not open
document type does not allow element "BODY" here

I'm guessing this is because it doesn't know the <head> tag is open .. am I right?

Can anyone help?

Thanks in advance!
Alex ...

encyclo

11:36 am on Aug 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alex, you're using XHTML-style notation (specifically, trailing slashes on your meta tags), but with a HTML doctype. The trailing slashes are not allowed in HTML.

Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
<head>
<title>Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="imagetoolbar" content="no">

<script type="text/javascript" src="includes/scripts/common.js"></script>
<style type="text/css" media="all">@import "includes/css/default.css";</style>
</head>
<body>
</body>
</html>

Until recently, the validator didn't catch this error at all and would have said that the page was valid. Now, it recognizes the fact that there is an error, but it's explanation is particularly obtuse as it can't pinpoint the exact problem.

Warboss Alex

12:08 pm on Aug 18, 2004 (gmt 0)

10+ Year Member



LOL. Thanks man, I actually read that in the FAQ afterwards.. :)

It seemed odd because the page validated as XHTML!

g1smd

11:12 pm on Aug 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I see this error on a lot of sites.

Don't use the extra closing / if you are coding in HTML 4.