3 ms·
It’s not that you’re allowed to omit the head element (you’re not, and you can’t), but that its start and end tags are optional. Same with the html and body ele
by chrismorgan 4y ago
It’s not that you’re allowed to omit the head element (you’re not, and you can’t), but that its start and end tags are optional. Same with the html and body elements. (These remarks apply to HTML syntax only; in XML syntax, which is certainly still a thing, you can (if you care not for validity) omit whatever elements you choose to, only needing some root element.)
As far as sources are concerned, the HTML spec is maintained by WHATWG, not W3C. The relevant citations start at https://html.spec.whatwg.org/multipage/semantics.html#document-metadata https://html.spec.whatwg.org/multipage/semantics.html#docume....
The normative reference on the necessity of <title> is in the content model for the head element:
> 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.
For the rest, you’re correct: the DOCTYPE is the only always-mandatory thing in a valid HTML document.
- Aeolun 4y ago> It’s not that you’re allowed to omit the head element (you’re not, and you can’t), but that its start and end tags are optional. That’s like calling a cheese sandwich without any cheese a cheese sandwich.
- ectopod 4y agoIt's not a sandwich recipe. The bread doesn't matter. The cheese does.
- tingletech 4y agoI think they are saying HTML implies the <head> for you - the <title> is still required.
- chrismorgan 4y agoIf you omit writing <head> and </head> in HTML syntax, there will still be a head tag in the parsed result. (This is different from XML syntax, where omitting the start and end tags means omitting the element as a whole so that there will be no head tag in the parsed result.)
- tingletech 4y agoconvo was about HTML 5 specifically (the W3C version). I've never heard HTML WHATWG called HTML 5.
- JimDabell 4y ago> I've never heard HTML WHATWG called HTML 5. Directly from the specification: > 1.2 Is this HTML5? > In short: Yes. — https://html.spec.whatwg.org/multipage/introduction.html#is-this-html5 https://html.spec.whatwg.org/multipage/introduction.html#is-...?