Hacker News new | ask | show | jobs
by debugnik 1396 days ago
From the head element section mentioned:

> 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 […].

> Otherwise: One or more elements of metadata content, of which exactly one is a title element […].

So it is required, not just suggested, for a web page, but not for all kinds of html documents; TIL. The parser still tries to parse head contents before body contents even if you omit the head tags, so a doctype followed by title is the shortest valid full page.

I didn't mention the doctype because I believe it isn't strictly speaking an element, just a preamble, but you're right, it's required as well.

1 comments

> I didn't mention the doctype because I believe it isn't strictly speaking an element, just a preamble, but you're right, it's required as well.

Funny thing, when I read “the only mandatory element in a valid HTML5 document”, I interpreted “element” in its generic English sense (piece, thing) rather than its HTML sense (node of type element, as distinct from text/comment/doctype/other-types-only-found-in-XML-syntax nodes).

True, I guess I would too if I were a native English speaker. Even when the words are almost identical in my language, I read them as programming jargon before plain English.