- From: Jukka K. Korpela <jkorpela@cs.tut.fi>
- Date: Mon, 28 Jul 2008 22:46:01 +0300
- To: <www-validator@w3.org>
Benjamin Hawkes-Lewis wrote:
> The HTML 3.2 specification includes an example of a "minimal HTML 3.2
> document":
>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
> > <TITLE>A study of population dynamics</TITLE>
>
> http://www.w3.org/TR/REC-html32#html
>
> If I paste that markup into the validator, it recognizes the document
> as HTML 3.2 but offers the following error:
>
> 'Line 2, Column 45: "HTML" not finished but document ended.'
I remember vaguely having discussed the empty body element issue
somewhere years ago. Anyway, the issue exists in HTML 4.01 too. For
example, the following fails validation with the same error message:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
> Unlike in HTML 4.01, the content of BODY is optional in the DTD:
The content of BODY is optional in HTML 4.01 Transitional, too, and my
test document above validates if you append e.g.
<body></body>
(Mere <body> will suffice too.)
My SGML is rusty, but I think the problem here is that the missing start
and end tags cannot be inferred when the element content is empty. If
there is just one nonspace character after </head>, it will be
recognized as starting the body, implying <body> before it, but where
there is no content, you cannot infer that this nothing is the content
of an element.
> (Before anybody asks, I'm not using HTML 3.2! Just curious why this
> doesn't validate.)
The issue has little if any practical value, though sometimes we want to
generate very small HTML documents programmatically, perhaps even with
empty body. Then it is best to include <body></body> to stay on the safe
side.
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Received on Monday, 28 July 2008 19:46:25 UTC