The default human language of each Web page can be programmatically determined.
On this page:
Rationale
The identification of a Web page's primary language enables assistive technology to correctly read the content. The lang attribute of the <html> element allows you to specify the language.
Required development and unit test techniques
To comply with this checkpoint, you must meet the following technique.
This technique is defined in WCAG 2.0 Level A Success Criterion 3.1.1 (link resides outside of ibm.com).
- Primary natural language: Identify primary natural language(s) using the
langattribute of the<html>element.
Note: The examples presented in the techniques are not exhaustive. They are meant to illustrate the spirit of this checkpoint.
HTML examples
-
Primary natural language: Identifying primary natural language(s) using the
langattribute of the<html>element.HTML example 1
Using the
langattribute to identify the language of the page helps ensure that assistive technologies like Braille software and screen readers will correctly pronounce the text. In the example below, thelangattribute is used to indicate that the page is in English. If the page is authored in a left-to-right language, only thelangattribute is required. For XHTML, use thexml:langattribute.<html lang="en" xml:lang="en">HTML example 2
When multiple
htmlelements are present, use thelangattribute on each one to identifying the primary natural language. The following example, shows twoiframesembedded in a Web page. Eachiframecontains anhtmlelement with alangattribute that identifies the primary natural language.<html lang="en">
...
<body>
<iframe ...>
<html lang="en">
...
</html>
</iframe ...><iframe ...>
<html lang="en">
...
</html>
</iframe ...>
</body>
</html>For additional information, refer to the WCAG 2.0 examples of using the lang attribute on the html element (link resides outside of ibm.com).
Required unit tests for HTML development technique 1
There are no manual test techniques for this example.
IBM® Lotus® Domino® examples
For techniques where there are no specific examples for your technology, use the HTML examples for guidance.
-
Primary natural language: Identify primary natural language(s) using the
langattribute of the<html>element.To comply with this technique, you must implement the following example.
You can use the
langattribute to specify the language on the page using Domino 7.02 or later.Domino example 1
On the form, create a new field with the following properties:
- In the Name field, enter $$HTMLTagAttributes.
- In the Type field, select Text and Computed for display.
- Go to the Hide tab. Under Hide Paragraph from, check Notes and Web browsers.
- In the Value pane, enter
{lang="en"}.
When you display the form in Domino, look at the source. The
langattribute is now added to the<html>element.Required unit tests for Domino development technique 1
There are no manual test techniques for this example.
Recommended development techniques
Although you do not have to implement the recommended techniques in order to comply with this checkpoint, you should review them since they can improve the accessibility and usability of the application.
- Use the
dirattribute: Identifying the primary text direction using thedirattribute of the<html>element.
Recommended development example 1
The following example illustrates the use of both the lang attribute and the dir attribute when a Web page is authored in a right-to-left language, such as Hebrew or Arabic.
<html lang="he" xml:lang="he" dir="rtl" >
Refer to the WCAG 2.0 Additional Techniques (Advisory) for Success Criterion 3.1.1 (link resides outside of ibm.com) for more techniques and examples.
©2012 IBM Corporation
Last updated August 1, 2012.
W3C Recommendation 11 December 2008: http://www.w3.org/TR/WCAG20/ (link resides outside of ibm.com)
Consortium for Informatics and Mathematics, Keio University), All Rights Reserved.
