In html, the lang attribute is used to specify the language of a web page. This is required for accessibility purposes as it helps to ensure that screen readers will correctly pronounce the content.
All pages in the School of Medicine (SOM) web system are tagged with the English language code. If content in another language is added to the SOM web system, that content needs to be properly tagged. This can be accomplished by adding the lang attribute to html elements such as paragraph or header tags.
<p lang="en">This is some content.</p>
<h2 lang="en">This is some content.</h2>
For Spanish, the language code is es. The html would look like this:
<p lang="es">This is some content.</p>
A list of other acceptable language codes can be found on this HTML Language Code Reference page.
To view and modify the html of a page, select the Text tab in the editor and add the lang attribute to the correct block(s) of text.
Defining the Language In Documents
Identifying the language in documents such as PDFs and Word documents is also important and is required to meet accessibility guidelines.
- W3C’s Setting the default language of a PDF document.
- W3C’s Setting a Title and Language of a Word Document.
- The University of Washington’s Language in Documents web page shows how to set the language for both pdfs and Word documents.
- UNC’s Digital Accessibility Office (DAO) provides documentation and training to help you make your documents accessible. View their documentation on document accessibility or sign up for their free document accessibility training.
WCAG Success Criterion 3.1.1 requires that web pages specify the default language of the page.
WCAG Success Criterion 3.1.2 requires that pages with parts in different languages have the languages of those parts specified too.
WebAIM’s Document and Content Language – there is a great audio recording demonstrating the issues a screen reader has pronouncing English text that has the language attribute of “cs” (Czech).