3 ms·
The title tag SHOULD occur in the head of a document[1] The <title> element is always used within a page's <head> block.[2] Just because browsers are comp
by munk-a 5y ago
The title tag SHOULD occur in the head of a document[1]
The <title> element is always used within a page's <head> block.[2]
Just because browsers are compatible[3] doesn't mean what you're doing is right. Twitter does set a title tag and thus that tag should be within a head block. They are leaning on browser compatibility mode to cover the fact that they aren't adhering to standards.
1. https://www.w3.org/Provider/Style/TITLE.html https://www.w3.org/Provider/Style/TITLE.html
2. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ti...
3. "HTML5-compliant browsers automatically create a <head> element if its tags are omitted in the markup. This auto-creation is not guaranteed in ancient browsers." https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#notes https://developer.mozilla.org/en-US/docs/Web/HTML/Element/he...
- JimDabell 5y ago> Twitter does set a title tag and thus that tag should be within a head block. It is in a <head> element. You don’t understand how HTML is parsed. The opening and closing tags for the <head> element are optional. That doesn’t mean the element isn’t there, it means that the element is always there. > They are leaning on browser compatibility mode to cover the fact that they aren't adhering to standards. They aren’t. See this comment I made and go ahead and paste that HTML into a validator: https://news.ycombinator.com/item?id=30475015 https://news.ycombinator.com/item?id=30475015 There is no error handling taking place, there is no browser compatibility mode involved. This is correct HTML that adheres to the standard being parsed normally. > [1], [2], [3] Why are you quoting a style guide written in 1992 and two unofficial sources when you could just as easily have referred to the actual HTML specification? > § 13.1.2.4 Optional tags > Certain tags can be omitted. > Note: Omitting an element's start tag in the situations described below does not mean the element is not present; it is implied, but it is still there. For example, an HTML document always has a root html element, even if the string <html> doesn't appear anywhere in the markup. — https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission https://html.spec.whatwg.org/multipage/syntax.html#syntax-ta... The HTML specification literally gives this as an example of a valid document: <!DOCTYPE HTML> <title>Hello</title> <p>Welcome to this example.</p> There are a great many ways in which people write broken HTML and the browser repairs things. This is not one of them. Omitting the opening and closing tags for the <head> element is perfectly correct HTML that adheres to the standard.