Re: W3C validator error - End tag for element "HEAD" which is not open

John Collins wrote:

> I’m the webmaster of and after running my
> site through the W3C markup validator.I got 7 errors.

Most of the errors are caused by mixing HTML and XHTML. The page declares an 
HTML 4.01 doctype, yet uses the special XHTML feature of ending an empty 
element like a meta element with “/>” and not just “/”.

If you change the doctype declaration at the start to

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

then most errors disappear. The remaining one is caused by a span element 
containing an h1 element, which is disallowed in all HTML versions. The 
obvious fix is to change the span element to a div element, though you need 
to check what impact this might have to styling (probably none, but worth 

> I understand most of the errors
> and I’ll fix them however this one really bothers me:
> Line 7, Column 489: end tag for element "HEAD" which is not open

This is a long and confusing story.
A brief summary:
When you use the “/>” notation, then by the formal rules of good old 
(non-XHTML) HTML, the “/” terminates the tag (such as link or meta tag), 
leaving the “>” as a data character. Now, the validator treats that data 
character as the start of document body, following the formal rules. The 
head element is implicitly closed, making the later </head> tag homeless.
The long story:
“Empty elements in SGML, HTML, XML, and XHTML”,


Received on Monday, 8 November 2010 08:55:44 UTC