act-rules.github.io
act-rules.github.io copied to clipboard
Multiple <title> tags in a web page
In HTML page has non-empty title we say:
While this is invalid in HTML, the HTML 5.2 specification describes what should happen in case of multiple titles, and titles outside the head element.
However, upon delving, I couldn't locate any explicit mention of this in the HTML 5.2 specifications.
Could someone direct me to the source where it details the expected behavior in cases of multiple
Thanks
Indeed, can't find it either (not even in parsing rules). It should be replaced by something like "browsers/AT behave consistently" (may need some extra testing that all the passed examples indeed pass in most common combinations...)
I'll address this with a PR, first making sure that browsers expose consistently the same title.
Outcomes of my test:
Scenario | Chrome | Safari | Firefox |
---|---|---|---|
2 titles, both in <head> |
The computed title is the 1st in list | The computed title is the 1st in list | The computed title is the 1st in list |
2 titles, both in <body> |
The computed title is the 1st in list | The computed title is the 1st in list | The computed title is the 1st in list |
2 titles, both after the <body> (parsing issue but it happens) |
The computed title is the 1st in list | The computed title is the 1st in list | The computed title is the 1st in list |
2 titles, 1 in <head> , 1 in <body> |
The computed title is the 1st in list (the one in head) | The computed title is the 1st in list (the one in head) | The computed title is the 1st in list (the one in head) |
2 titles, 1 in <head> , 1 after the <body> (parsing issue but it happens) |
The computed title is the 1st in list (the one in head) | The computed title is the 1st in list (the one in head) | The computed title is the 1st in list (the one in head) |
2 titles, 1 in <body> , 1 after the <body> (parsing issue but it happens) |
The computed title is the 1st in list (the one in body) | The computed title is the 1st in list (the one in body) | The computed title is the 1st in list (the one in body) |
2 titles, 1 in <head> , 1 inside a shadowroot (open and closed) |
The computed title is the 1st in list (the one in head), shadowroot title is ignored | The computed title is the 1st in list (the one in head), shadowroot title is ignored | The computed title is the 1st in list (the one in head), shadowroot title is ignored |
Proceeding with the PR.
It is defined here in the HTML Standard:
The title element of a document is the first title element in the document (in tree order), if there is one, or null otherwise.
https://html.spec.whatwg.org/multipage/dom.html#the-title-element-2
However, upon delving, I couldn't locate any explicit mention of this in the HTML 5.2 specifications.
Do you really mean the HTML 5.2 specification? The HTML 5.2 spec was obsoleted in 2019 and replaced by the WHATWG HTML Standard: https://www.w3.org/html/
Completed