Description
In the Understanding of 3.1.2 Language of Parts, I think we need to more clearly define the expected outcome for cases where the computed accessible name is derived from an (or the sum of) element's content.
Assumption: All examples are part of an English (lang="en") page.
- Scenario 1:
Failure, missing lang
<html lang="en"> ... <a href="#">Italiano</a> ... </html>
- Scenario 2:
Pass, lang properly set
<html lang="en"> ... <a href="#" lang="it">Italiano</a> ... </html>
- Scenario 3:
IMO ambiguous.
<html lang="en"> ... <a href="#" title="Italian"><span lang="it">Italiano</span></a> ... </html>
Based on the last example in the Understanding Language of Parts (The element's content and attribute values are in different languages), it appears this pattern is intended to pass.
However, it's a confusing implementation. The accessible name is derived solely from the span's content, which is correctly marked with lang="it". Yet the link element itself lacks a lang attribute, which cause screen readers, like VO, to announce the link using the page's default language (English), resulting in a mismatched accent or pronunciation. The title attribute (in English) does not contribute to the accessible name and does not resolve the issue.
Without additional context, it would be cleaner and more reliable to write:
<a href="#" lang="it">Italiano</a>
If the current implementation (with title) is intentional, we should provide more explanation to clarify the rationale, why the title is included and how it supports accessibility in that particular scenario. - Scenario 4:
This scenario is similar to the previous one but omits the use of the title attribute. In my opinion, unless this implementation is essential for a specific reason, it should be considered a failure of the Success Criterion, since the intended outcome, having the link text "Italiano" announced with the correct pronunciation, is not achieved, as it is instead read with an English accent.
<html lang="en"> ... <a href="#"><span lang="it">Italiano</span></a> ... </html>
- Scenario 5:
One could argue that "Read this book" doesn't necessarily need to be part of the link, but let's set that aside for now.
<html lang="en"> ... <a href="#">Read this book: <span lang="it">La Divina Commedia</span></a> ... </html>
The accessible name contains a mixture of languages (English + Italian). There is currently no way to set multiple languages for a single accessible name.
In this case, I think we should accept the scenario due to practical limitations (and clarify that in the Understanding). However, scenarios like 3 and 4 (where the entire name is in a different language) are more problematic and arguably should fail, unless this behavior is essential for the content.
Also, in light of the above discussion, the final example titled "The element's content and attribute values are in different languages" should be better described.
This example assumes that the page's default content is in English. The link's title attribute is in English, but the nested span element that contains the word Español has a lang="es" attribute.
<a title="Spanish" href="qa-html-language-declarations-es.html"><span lang="es">Español</span></a>
We should also clarify whether this solution is:
- Always acceptable, even if the accessible name of the link (in Spanish) is announced with an English accent, and, if so, explain why the presence of the title attribute is considered sufficient.
- Acceptable only in specific contexts, and if that's the case, clearly explain why it is acceptable in this particular scenario, so that users can understand the conditions under which this pattern is appropriate.