Closed cptvitamin closed 4 years ago
Should xml:lang
be allowed as a pass in any test cases?
The current HTML recommendation says:
Authors must not use the lang attribute in the XML namespace on HTML elements in HTML documents.
https://www.w3.org/TR/html52/dom.html#the-lang-and-xmllang-attributes https://html.spec.whatwg.org/multipage/dom.html#the-lang-and-xml:lang-attributes
In XHTML there was a lot of spec churn on this:
XHTML 1.0 Rec
Use both the lang and xml:lang attributes when specifying the language of an element. https://www.w3.org/TR/xhtml1/#C_7
XHTML 1.1 Rec - First Edition
On every element, the lang attribute has been removed in favor of the xml:lang attribute https://www.w3.org/TR/2001/REC-xhtml11-20010531/changes.html#a_changes
XHTML 1.1 Rec - Second Edition
The updated recommendation removed the statement saying the lang attribute has been removed in favor of the xml:lang attribute
https://www.w3.org/TR/xhtml11/changes.html#a_changes
The W3 validator does not flag validation errors for XHTML 1.0 and 1.1 documents with lang but no xml:lang
@dd8 good point. However, I think the ACT-Rules TF takes the position that they are not a validator, and they also do not worry too much about what host languages require. They prioritize real-world impact on accessibility for the end user. If you look at the tests for the <title>
element you will find that ACT-Rules allows for two or more to be defined, even though HTML5 explicitly prohibits this, and also that the <title>
element does not have to be contained in the <head>
, which HTML5 also explicitly states it must. The argument is that testing has shown Access Technology will take the first <title>
element it finds and expose it to the user. ¯_(ツ)_/¯
Yep, but does the xml:lang
attribute have any effect in any AT?
Steve Faulkner has a demo showing it has no effect in JAWS: https://www.youtube.com/watch?v=3kDjRZtX834
I did some testing:
VoiceOver 10.13 with Safari 12.1.1 - lang='fr'
changes the voice to French, but xml:lang='fr'
is ignored
NVDA 2018.3 with IE11 - lang='fr'
changes the voice to French, but xml:lang='fr'
is ignored
NVDA 2018.3 with FF67 - lang='fr'
changes the voice to French, but xml:lang='fr'
is ignored
In NVDA 2018 you need to switch the synthesiser to eSpeak NG to enable language switching. The default NVDA synthesiser is now Windows OneCore, which doesn't support other languages by default on an English installation.
We've done some testing on lang
vs xml:lang
lang
is very well supported and works in all tested browser/AT combinations
https://www.powermapper.com/tests/screen-readers/content/html-page-lang/
xml:lang
is very poorly supported - it works if you use Chrome on Mac or Windows, but not if you use Firefox, IE, Safari or iOS
https://www.powermapper.com/tests/screen-readers/content/html-page-xml-lang/
There's an argument that xml:lang
does not meet the threshold for 'accessibility supported' since it's only supported by one user agent (Chrome) and the accessibility-supported definition requires user agents (plural).
The Web content technology must have accessibility-supported user agents that are available to users
https://www.w3.org/TR/WCAG21/#dfn-accessibility-supported
5.2.4 Only Accessibility-Supported Ways of Using Technologies Only accessibility-supported ways of using technologies are relied upon to satisfy the success criteria. Any information or functionality that is provided in a way that is not accessibility supported is also available in a way that is accessibility supported. (See Understanding accessibility support.)
This rule has been updated to long exclusively at lang
attributes in text/html
document. Browsers do not support using xml:lang
in those text/html
pages. A separate rule could be created for application/xml
, although the benefit of that seems minimal, since very few pages on the web use this.
I think there may be an issue with this test case:
{ "testcaseId": "5f5094197bb84c8f5524f97b9fc5624f18e9dff0", "url": "https://act-rules.github.io/testcases/bf051a/5f5094197bb84c8f5524f97b9fc5624f18e9dff0.html", "expected": "inapplicable", "ruleId": "bf051a", "ruleName": "Validity of HTML Lang attribute", "rulePage": "https://act-rules.github.io/rules/bf051a" }
The test case is:
<html xml:lang=""></html>
It's marked as inapplicable, but AFAIK this is a failure. See Failed example #2
What's more confusing is that in Alfa's implementation report, it is marked as inapplicable, and in aXe's it's marked as a pass.