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

HTML page lang and xml:lang match - problems with 2 examples (5b7ae0) #1172

Closed
dd8 opened this issue Feb 15, 2020 · 6 comments
Closed

HTML page lang and xml:lang match - problems with 2 examples (5b7ae0) #1172

dd8 opened this issue Feb 15, 2020 · 6 comments
Assignees

Comments

@dd8
Copy link
Collaborator

dd8 commented Feb 15, 2020

Inapplicable example 3

The HTML spec defines a lang attribute equal to the empty string as meaning unknown language - sp
xmll:lang='' doesn't match lang=fr and should be a failure:
https://html.spec.whatwg.org/multipage/dom.html#the-lang-and-xml:lang-attributes

<html lang="fr" xml:lang=""></html>

https://act-rules.github.io/rules/5b7ae0#inapplicable-example-3

Inapplicable example 5

A lang that's only blanks behaves very differently to a lang that's the empty string. See final example on this test page:
https://qa.powermapper.com/Tests/ACT-R/primary-ext-lang.html

I think this should also be a failure because they do different things.

<html lang=" " xml:lang=""></html>

https://act-rules.github.io/rules/5b7ae0#inapplicable-example-5

Note: this probably affects the applicability as well

@jeeyyy jeeyyy changed the title HTML page lang and xml:lang match - problems with 2 examples HTML page lang and xml:lang match - problems with 2 examples (5b7ae0) Mar 10, 2020
@Jym77
Copy link
Collaborator

Jym77 commented Apr 22, 2020

Yes, we can probably extend the applicability to test (and fail) empty tags. The prolem I see with that is that we are only matching the primary language tag, not the full string (i.e. lang=en-US" xml:lang=en-UK" passes the rule). So, if the empty tags are applicable that makes the expectation more tricky to express.

This can maybe be solved with two expectations (1. the attributes are not empty; 2. the primary language tags match).

@WilcoFiers WilcoFiers self-assigned this Jul 14, 2021
@WilcoFiers WilcoFiers removed their assignment Jul 27, 2021
@WilcoFiers
Copy link
Member

Linking some research: #668 (comment) that may be relevant for this issue. Thanks for the reminder on that Mark.

@WilcoFiers
Copy link
Member

@dd8 In what scenario will inapplicable example 8 cause a screen reader to mispronounce content? I get the "unknown language" argument, but I'd like to know that causes a real-world accessibility problem.

@dd8
Copy link
Collaborator Author

dd8 commented Jul 15, 2022

@WilcoFiers We've just done some testing on 10 different browser combos on macOS and Windows (Chrome, Edge, Firefox, Safari, IE11 with VO, NVDA, JAWS and Narrator).

When calculating language:

  • all tested browsers ignore xml:lang if pages are served as text/html (which is consistent with spec)
  • CSS :lang() follows spec in all browsers (uses xml:lang if both lang and xml:lang are specified on pages served as application/xml+xhtml, and uses lang on pages served as text/html)
  • for a11y tree all browsers use lang if both lang and xml:lang are specified on text/html pages (which is consistent with spec)
  • for a11y tree most browsers use lang if both lang and xml:lang are specified on application/xml+xhtml pages (which is opposite of CSS and opposite of what spec and MDN say)
  • only Edge with Narrator follows spec:
    uses lang if both lang and xml:lang are specified on pages served as text/html
    uses xml:lang if both lang and xml:lang are specified on pages served as application/xml+xhtml
  • Edge with Narrator has a problem with lang='de' xml:lang='fr' and treats this as French
  • Edge with Narrator has a problem with lang='de' xml:lang='' and treats this as unknown language and falls back to system language

Note: Firefox on macOS doesn't support language changes at all

So I don't think the rule detects any real-world accessibility problems because the applicability is restricted to text/html documents (which always ignore xml:lang per specification). According to the spec (and confirmed by testing) these all behave identically for text/html pages:

<html lang="fr">
<html lang="fr" xml:lang="de">
<html lang="fr" xml:lang="">

<p lang="fr">
<p lang="fr" xml:lang="de">
<p lang="fr" xml:lang="">

The above examples do behave differently if the page is served as application/xml+xhtml

If the content type in applicability was changed to application/xml+xhtml then it would detect problems, although these types of page are very rare - about 0.05% of all pages, and mismatched lang/xml:lang will be even rarer:
https://commoncrawl.github.io/cc-crawl-statistics/plots/mimetypes

Edit: there have been updates to this adding missing detail

@dd8
Copy link
Collaborator Author

dd8 commented Jul 15, 2022

And here are the test results

Test VO macOS 12.3/Chrome 103 VO macOS 12.3/Safari 15.4 VO macOS 12.3/FF 102 Chrome 103/NVDA 2021.2 FF91/NVDA 2021.2 IE11/NVDA 2021.2 Chrome 103/JAWS 2021.2107 FF91/JAWS 2021.2107 IE11/JAWS 2021.2107 Edge 103/ Narrator Win 10
html lang (text/html) lang used lang used Ignored lang used lang used lang used lang used lang used lang used lang used
html xml:lang (text/html) Ignored Ignored Ignored Ignored Ignored Ignored Ignored Ignored Ignored Ignored
html lang (application/xml+xhtml) lang used lang used Ignored lang used lang used lang used lang used lang used lang used lang used
html xml:lang (application/xml+xhtml) xml:lang used Ignored Ignored xml:lang used Ignored Ignored xml:lang used Ignored Ignored xml:lang used
html lang withxml:lang mismatch (application/xml+xhtml) lang used lang used Ignored lang used lang used lang used lang used lang used lang used xml:lang used
html lang with xml:lang empty (application/xml+xhtml) lang used lang used Ignored lang used lang used lang used lang used lang used lang used xml:lang used unknown language, defaults to system language
p lang (text/html) lang used lang used Ignored lang used lang used lang used lang used lang used lang used lang used
p xml:lang (text/html) Ignored Ignored Ignored Ignored Ignored Ignored Ignored Ignored Ignored Ignored
p lang (application/xml+xhtml) lang used lang used Ignored lang used lang used lang used lang used lang used lang used lang used
p xml:lang (application/xml+xhtml) Ignored Ignored Ignored Ignored Ignored Ignored xml:lang used Ignored Ignored xml:lang used
p lang xml:lang mismatch (application/xml+xhtml) lang used lang used Ignored lang used lang used lang used lang used lang used lang used lang used
p lang with xml:lang empty (application/xml+xhtml) lang used lang used Ignored lang used lang used lang used lang used lang used lang used xml:lang=‘de’ used

@dd8
Copy link
Collaborator Author

dd8 commented Jan 25, 2024

Closing because rule was deprecated in #2086

@dd8 dd8 closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants