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.
UK EVENTAttend ffconf.org 2024
The conference for people who are passionate about the web. 8 amazing speakers with real human interaction and content you can't just read in a blog post or watch on a tiktok!
£249+VAT - reserve your place today
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 😉