For accessibility, do I need to write lang="xx"
as well as xml:lang="xx"
attributes in XML (XHTML5) to indicate human natural language and language changes? I am always writing XML ( = XHTML5 ) always served with the correct MIME type, that is: served as application/xhtml+xml
(iirc).
Can I drop the current duplicate lang="xx"
attributes? I’m using both attribute forms everywhere currently, always with matching language codes.
I’m unsure whether or not assistive technology and user agents understand xml:lang in XML / XHTML.
You very likely can skip the duplicate attribute from the XML namespace for assistive technology.
As PowerMapper confirms, it’s not used in screen readers.
Actual Result: causes problems in 48 screen reader / browser combinations
I also found this Rule for accessibility conformance testing (ACT) Deprecated: HTML page lang and xml:lang attributes have matching values:
This rule has been deprecated, as modern screen readers no longer use xml:lang when the lang attribute is given, regardless of which MIME type the page is served with. This rule is not maintained anymore and should not be used.
However, as Hermann mentions:
When using other XML parsers, however (such as the
lang()
function in XSLT) you can't rely on thelang
attribute being recognized.
So, while the same article continues
[…] you do not need the
lang
attribute. Thexml:lang
attribute alone will suffice.
You definitely need it to practically support assistive technology.