There seems to be confusion about the minimal set of elements that make a valid HTML5 page.
(Amended on prompting from Tab Atkins and Mathias Bynens in comments below.)
The simplest valid document is
title element is required in most situations, but when a higher-level protocol provides title information, e.g. in the Subject line of an e-mail when HTML is used as an e-mail authoring format, the
title element can be omitted.
Assuming you’re writing a web page rather than an HTML email, you need the
title element, although technically it can be blank.
<!doctype html> <title></title>
However, you shouldn’t do that. Failure to specify a character encoding which can introduce an obscure but real security vulnerability. So, the simplest valid and secure document looks like this:
<!doctype html> <meta charset=utf-8> <title>blah</title> <p>I'm the content
(You don’t actually need the content, of course, but it’s a pretty rubbish web page without it, and an empty
title isn’t much good.)
However, for accessibility reasons, you should declare the natural language of the document (English/ French/ Swahili) on the
html element, which therefore means you need that element (note that you don’t need to close it, though):
<!doctype html> <html lang=en> <meta charset=utf-8> <title>blah</title> <p>I'm the content
If you’re planning to use AppCache to enable offline applications, you’ll need the
html element as the
manifest attribute goes there.
Internet Explorer 9 Developer Preview 3 and its antecedents can’t apply CSS to new HTML5 elements without a
body element. (Try it without
body and with
So if you’re attempting to do that, the smallest valid, secure, screenreader-accessible and stylable-in-IE HTML5 page you can have is
<!doctype html> <html lang=en> <meta charset=utf-8> <title>blah</title> <body> <p>I'm the content
Just because you can do this doesn’t mean you should, of course. Depending on your colleagues, it could be confusing and thus a maintainability nightmare.
I use the
head element, and close those tags that need closing (although I donâ€™t bother with trailing slashes on self-closing elements).
So the minimal valid, secure, screenreader-accessible and stylable-in-IE HTML5 page (not email) that it easily readable and maintainable (subjective, of course) is probably
<!doctype html> <html lang=en> <head> <meta charset=utf-8> <title>blah</title> </head> <body> <p>I'm the content</p> </body> </html>
(PS, I co-wrote a book!)