Forum Moderators: open

Message Too Old, No Replies

W3C Validation -- end tag for element "HEAD" which is not open

Explanation for cause of validation failure

         

dnimrodx

1:34 pm on Feb 27, 2005 (gmt 0)

10+ Year Member



Hello,

I am getting some validation errors from W3C's Markup Validation Service. It goes like so:

[pre]1. Line 11, column 6: end tag for element "HEAD" which is not open
2. Line 14, column 31: document type does not allow element "BODY" here[/pre]

In my ASP-generated HTML page one can find:

[pre]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- Begin <html> -->
<html>
<!-- Begin <head> -->
<head>
<title>Vertigo home page</title>
<meta http-Equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="src/css/layout.css" />
</head>
<!-- End <head> -->
<!-- Begin <body> -->
<body onLoad="preloadImages();">[/pre]

My question is: should I get rid of the remarks before the BODY tag or is there a different issue causing this?

Thank you very much.

Dave

ronin

2:31 pm on Feb 27, 2005 (gmt 0)

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



Certainly it wouldn't hurt to delete the comments.

Comments are usually included to explain to subsequent developers what each part of the code does. It's unusual to explain just before the opening <body> tag that this is where the body of the document begins.

I would guess it's the use of unescaped angle brackets within the comments that is tripping up the validator. There don't seem any other obvious errors.

One other thing though... you're using a 4.01 doctype, so you don't need a trailing slash in the link tag - that's an xhtml convention.

dnimrodx

5:04 pm on Feb 27, 2005 (gmt 0)

10+ Year Member



Thanks for your reply.

I've taken all pre-body comments out of the pages and fixed the link tag. It now looks like this:

[pre]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Vertigo home page</title>
<meta http-Equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="src/css/layout.css">
</head>
<body onLoad="preloadImages();">
[/pre]

However I still get the exact same errors:

[pre]1. Line 11, column 6: end tag for element "HEAD" which is not open
2. Line 14, column 31: document type does not allow element "BODY" here
[/pre]{to just name a few}

Why is this happening?

[edited by: dnimrodx at 5:06 pm (utc) on Feb. 27, 2005]

pageoneresults

5:06 pm on Feb 27, 2005 (gmt 0)

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



<link rel="stylesheet" type="text/css" href="src/css/layout.css"[b] /[/b]>

You are using an XHMTL closing tag on your link rel. Try removing that and see what happens...

<link rel="stylesheet" type="text/css" href="src/css/layout.css">

Hmmm, your first example has a closing XHTML tag for the link rel. Your second example does not.

Ooops, didn't read ronin's last comment...

One other thing though... you're using a 4.01 doctype, so you don't need a trailing slash in the link tag - that's an xhtml convention.

[edited by: pageoneresults at 5:09 pm (utc) on Feb. 27, 2005]

dnimrodx

5:08 pm on Feb 27, 2005 (gmt 0)

10+ Year Member



Pageonresult, that was it! Why it was displaying I don't know... what I do know is that by removing the trailing slash from the link tag the validator stopped complaining...

Thanks a lot!

[EDIT:]

Hmmm, your first example has a closing XHTML tag for the link rel. Your second example does not.

I was in the process of uploading the updated page onto my (too-damn-slow) web host provider when I changed the message -- I hadn't tested it yet...[/EDIT]