6 ms·
What I find interesting is that the <title> attribute is styled and visible in the page, but not technically in the body. I didn't even know that was possible.
by martin-adams 13y ago
What I find interesting is that the <title> attribute is styled and visible in the page, but not technically in the body. I didn't even know that was possible. I'm guessing it's because it's not inside a <head> tag.
- cheeaun 13y agoThe browser will still render it inside a <head> tag. Just need to display:block both <head> and <title> (by default display:none I suppose)
- kevincennis 13y agoYeah, the first time I saw something like that I was pretty surprised. You can actually display:block script elements, too. Kinda cool if you need to put a code example on a page and also have that same code actually execute.
- emhart 13y agoMind blown. That's phenomenally cool. Thanks for the tip.
- lnanek2 13y agoYeah, browser must be assuming everything is body since there is no proper html, head, or body elements. This makes title an unknown tag since it is only defined in the head. Standard for unknown tags is to show the content. Thus why you can put something to show up for someone with no JavaScript in script tags.
- flomo 13y agoThe 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
- mathias 13y agoSee http://mathiasbynens.be/notes/css-hidden-elements http://mathiasbynens.be/notes/css-hidden-elements