On this page:
- Why use the lang attribute preview mode?
- How does the lang attribute preview mode work?
- How do I use the lang attribute preview mode?
Why use the lang attribute preview mode?
Developers should define the natural language of a document to ensure that screen readers and other user agents understand what language the document should be interpreted in. Specifically, if a document contains multiple inline language choices, screen readers and other assistive technology types must know what the default language type is to ensure they can appropriately switch between languages. If the lang attribute is not used or is mislabeled, assistive technologies may misinterpret the content. This preview mode allows testers to easily evaluate the language is specified for all content.
How does the lang attribute preview mode work?
This preview mode allows users to view a list of all elements that have a language specified. Any element with the lang attribute will be displayed in the list in Access Assistant. Users may select any element in the list to highlight it on the page. Users may select the Highlight All Lang Attributes button to highlight all items on the page that have a lang attribute specified.
Testers should evaluate all highlighted elements to determine that the correct language is specified. Testers should also evaluate all content that is in a different language from the default but has not been highlighted by the preview mode. This would indicate that a lang attribute was not appropriately specified for that content.
How do I use the lang attribute preview mode?
For every page being tested, evaluate the contents of the page with language attributes highlighted. This can be done with this Preview Mode as follows:
- Launch Access Assistant from the site that is being tested and navigate to a page.
- In Access Assistant, navigate to the project and report where violation instances will be reported and find the module for the page being tested OR create the module if the page has not yet been tested at all.
- In Access Assistant, select the Preview Modes button in the toolbar header bar.
- Select the "Lang Attribute" link on the subsequent page.
- To highlight all language attributes, select the Highlight All Lang Attributes. If you want to inspect a particular element that has a lang attribute specified, select the item in the list. The value specified for each lang attribute will be displayed with the element.
- Evaluate the page and determine whether the language attribute has been specified for all elements with a language different from the default document language, and that the specified language matches the written language. Add an instance for any elements that do not meet the above best practices:
- Select the Manual Test button in the module toolbar.
- Filter the Best Practices to those of Media Type, Language and Content.
- Select the appropriate Best Practice. Possible Best Practices include:
- Ensure the language of a document is set
- Ensure changes in natural language are identified inline
- On the subsequent screen, select the Add Instance button and complete the form to create a violation instance for the page or elements on the page that are in violation.