1

I was reading up on D3, and one of the slides mentioned the most minimal HTML page by Paul Irish.

<!DOCTYPE html>
<meta charset="utf-8">
<body>
Hello, world!

I understand exactly what this HTML does -- however, how in the world could this be valid HTML5, and further, is it standards compliant? Or is this just a case of it works, but it bends the rules?

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145

1 Answers1

4

The HTML5 spec describes what tags can be omitted under Tag omission in text/html. However, the spec states:

A non-normative description of whether, in the text/html syntax, the start and end tags can be omitted. This information is redundant with the normative requirements given in the optional tags section, and is provided in the element definitions only as a convenience.

Since it's non-normative, we can not rely on it for conformance checking. In the normative optional tags section, it lists:

An html element's start tag may be omitted if the first thing inside the html element is not a comment.

An html element's end tag may be omitted if the html element is not immediately followed by a comment.

A head element's start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.

A head element's end tag may be omitted if the head element is not immediately followed by a space character or a comment.

A body element's start tag may be omitted if the element is empty, or if the first thing inside the body element is not a space character or a comment, except if the first thing inside the body element is a meta, link, script, style, or template element.

A body element's end tag may be omitted if the body element is not immediately followed by a comment.

So it seems the document is valid save for the missing <title>, which is probably why the w3 validator complains. There are further indications that <title> is required. First, the Content model section for <head>, which is normative, states:

If the document is an iframe srcdoc document or if title information is available from a higher-level protocol: Zero or more elements of metadata content, of which no more than one is a title element and no more than one is a base element.

Otherwise: One or more elements of metadata content, of which exactly one is a title element and no more than one is a base element.

And the spec states:

A normative description of what content must be included as children and descendants of the element.