act-rules / act-rules.github.io

Accessibility conformance testing rules for HTML
https://act-rules.github.io/
Other
131 stars 67 forks source link

Multiple <title> tags in a web page #2168

Open giacomo-petri opened 3 months ago

giacomo-petri commented 3 months ago

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 tags?</p> <p>Thanks</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Jym77"><img src="https://avatars.githubusercontent.com/u/19969498?v=4" />Jym77</a> commented <strong> 3 months ago</strong> </div> <div class="markdown-body"> <p>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...)</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/giacomo-petri"><img src="https://avatars.githubusercontent.com/u/106394951?v=4" />giacomo-petri</a> commented <strong> 3 months ago</strong> </div> <div class="markdown-body"> <p>I'll address this with a PR, first making sure that browsers expose consistently the same title.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/giacomo-petri"><img src="https://avatars.githubusercontent.com/u/106394951?v=4" />giacomo-petri</a> commented <strong> 2 months ago</strong> </div> <div class="markdown-body"> <p>Outcomes of my test:</p> <table> <thead> <tr> <th>Scenario</th> <th>Chrome</th> <th>Safari</th> <th>Firefox</th> </tr> </thead> <tbody> <tr> <td>2 titles, both in <code><head></code></td> <td>The computed title is the 1st in list</td> <td>The computed title is the 1st in list</td> <td>The computed title is the 1st in list</td> </tr> <tr> <td>2 titles, both in <code><body></code></td> <td>The computed title is the 1st in list</td> <td>The computed title is the 1st in list</td> <td>The computed title is the 1st in list</td> </tr> <tr> <td>2 titles, both after the <code><body></code> (parsing issue but it happens)</td> <td>The computed title is the 1st in list</td> <td>The computed title is the 1st in list</td> <td>The computed title is the 1st in list</td> </tr> <tr> <td>2 titles, 1 in <code><head></code>, 1 in <code><body></code></td> <td>The computed title is the 1st in list (the one in head)</td> <td>The computed title is the 1st in list (the one in head)</td> <td>The computed title is the 1st in list (the one in head)</td> </tr> <tr> <td>2 titles, 1 in <code><head></code>, 1 after the <code><body></code> (parsing issue but it happens)</td> <td>The computed title is the 1st in list (the one in head)</td> <td>The computed title is the 1st in list (the one in head)</td> <td>The computed title is the 1st in list (the one in head)</td> </tr> <tr> <td>2 titles, 1 in <code><body></code>, 1 after the <code><body></code> (parsing issue but it happens)</td> <td>The computed title is the 1st in list (the one in body)</td> <td>The computed title is the 1st in list (the one in body)</td> <td>The computed title is the 1st in list (the one in body)</td> </tr> <tr> <td>2 titles, 1 in <code><head></code>, 1 inside a shadowroot (open and closed)</td> <td>The computed title is the 1st in list (the one in head), shadowroot title is ignored</td> <td>The computed title is the 1st in list (the one in head), shadowroot title is ignored</td> <td>The computed title is the 1st in list (the one in head), shadowroot title is ignored</td> </tr> </tbody> </table> <p>Proceeding with the PR.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/dd8"><img src="https://avatars.githubusercontent.com/u/16352274?v=4" />dd8</a> commented <strong> 3 weeks ago</strong> </div> <div class="markdown-body"> <p>It is defined here in the HTML Standard:</p> <blockquote> <p>The title element of a document is the first <a href="https://html.spec.whatwg.org/multipage/semantics.html#the-title-element">title</a> element in the document (in <a href="https://dom.spec.whatwg.org/#concept-tree-order">tree order</a>), if there is one, or null otherwise.</p> </blockquote> <p><a href="https://html.spec.whatwg.org/multipage/dom.html#the-title-element-2">https://html.spec.whatwg.org/multipage/dom.html#the-title-element-2</a></p> <blockquote> <p>However, upon delving, I couldn't locate any explicit mention of this in the HTML 5.2 specifications.</p> <p>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: <a href="https://www.w3.org/html/">https://www.w3.org/html/</a></p> </blockquote> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>