Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple <title> tags in a web page #2168

Open
giacomo-petri opened this issue Mar 22, 2024 · 4 comments
Open

Multiple <title> tags in a web page #2168

giacomo-petri opened this issue Mar 22, 2024 · 4 comments
Assignees

Comments

@giacomo-petri
Copy link
Collaborator

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 <title> tags?

Thanks

@Jym77
Copy link
Collaborator

Jym77 commented Mar 23, 2024

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...)

@giacomo-petri
Copy link
Collaborator Author

I'll address this with a PR, first making sure that browsers expose consistently the same title.

@giacomo-petri giacomo-petri self-assigned this Mar 24, 2024
@giacomo-petri
Copy link
Collaborator Author

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.

@dd8
Copy link
Collaborator

dd8 commented Jun 13, 2024

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants