4 ms·
The head tag is actually optional (under most conditions) -- supposedly because Netscape patented it. The title shows up because it's set to display:block.
by flomo 13y ago
The head tag is actually optional (under most conditions) -- supposedly because Netscape patented it. The title shows up because it's set to display:block.
- recursive 13y agoI'd love to see a source on that. <head> is part of the official HTML standard.
- dragonwriter 13y agoThe parsing rules in the WHATWG HTML standard (Sec. 12) is one source. In the "before head" insertion mode (Sec. 12.2.5.4.3) [1] of a compliant HTML parser, encountering a start tag other than for an HTML or HEAD element is defined as inserting a HEAD element and transitioning to the "in head" insertion mode, reprocessing the encountered start tag. So a bare TITLE start tag not enclosed in a HEAD automatically creates an enclosing HEAD element. I think this actually largely reproduces the behavior of the HTML4 DTD, in which, according to Google [2] the HEAD element is optional. [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#the-before-head-insertion-mode http://www.whatwg.org/specs/web-apps/current-work/multipage/... [2] https://developers.google.com/speed/articles/optimizing-html https://developers.google.com/speed/articles/optimizing-html
- recursive 13y agoI meant a source on Netscape patenting an html tag, not on the fact that it's optional.
- flomo 13y agoSorry, can't dig up a source. It's the explanation I've heard for IE Classic's handling of head elements.
- dragonwriter 13y agoFrom a little research, it seems that that explanation is wrong (it sounds like a web dev urban legend dramatizing the "patents mess up everything on the internet" meme). A 1993 draft spec for HTML [1] specifies the ability to include the elements that spec specified as HEAD and BODY elements free floating within the HTML without HEAD and BODY was required of parsers to support "old style documents" using "deprecated" HTML syntax. This tells us two things: 1) The "support TITLE outside of HEAD" behavior was a necessary to support legacy documents in 1993, before Netscape (as the Mosaic Communications Corporation) was founded in 1994, and 2) The HEAD element itself existed before Netscape was founded in 1994. This both provides a more likely explanation for the behavior than any Netscape patent and illustrates that it is unlikely that Netscape could have patented the element in any case. [1] http://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt http://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt
- flomo 13y agoThanks for the additional research and of course that makes perfect sense. I shall stop spreading that urban legend.