I was surprised today when I discovered that the HTML response from https://twitter.com does not include a
<head> tag (or
<body> for that matter), though does include tags (e.g.
<meta charset>) that are only valid as children of
Today I learned that this is ok.
Per the HTML spec:
A head element's start tag can be omitted if the element is empty, or if the first thing inside the head element is an element.
A head element's end tag can be omitted if the head element is not immediately followed by ASCII whitespace or a comment.
Similar applies to
<body>, see: https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission