Yesterday I posted a little historical insight into why the closing </p>
tag is optional, but in passing I mentioned you'll not see any new elements proposed for the head
element.
Though I can't refer to any specifications (partly because I'm writing this from a gym treadmill!), here's the reason why.
It was the good young Mr Harry Roberts who called me out on twitter.
The reasoning is obvious once you see it, and I'll have to pass credit to Jeremy Keith for making me realise why.
You won't see new elements added to the head
element because the parsing algorithm only allows for title, meta, style, script, base and link.
Today, if your browser spots anything else in the <head>
tag, it'll land in the body
element in the DOM.
You can see this happening in Hixie's DOM visualisation tool - the "invalid" positioned element gets tossed out into the body.
If a new element was created to go in the <head>
all existing instances of browsers up to that point would eject the element into the body and it would mess things up.
This would completely break the backwards compatible feature of HTML, which, as we've seen, hasn't happened yet.
For this reason, you'll find the link
's rel
is repurposed ALL the time (link rel="preconnect", etc) to get around this problem.
So, that's why head
is locked and you won't see new elements designated beyond the body
element.
Written from a treadmill on my 41st birthday, so you'll forgive any typos 😉