Accessibility
The dir attribute is correctly set according to the language
The purpose of this audit is to verify whether the dir
attribute on HTML pages
has been correctly set according to the language used. This audit is part of an
accessibility check and specifically focuses on Success Criterion 3.1.2 of the Web Content
Accessibility Guidelines (WCAG) 2.1.
Importance of Valid Code for Accessibility
Valid code plays a crucial role in ensuring accessibility for all users. By correctly
setting the dir
attribute, we improve the experience for individuals who rely
on assistive technologies, such as screen readers, to access and comprehend content. Success
Criterion 3.1.2 of WCAG 2.1 aims to ensure that the intended meaning and sequencing of
information remains consistent, regardless of the presentation format.
Use Cases for Success Criterion 3.1.2
Success Criterion 3.1.2 is particularly beneficial for people who rely on assistive
technologies to access content presented in spoken form. By setting the dir
attribute correctly, users can better understand the structure and meaning of content. This
criterion helps ensure that the order and flow of information are preserved when the content
is converted to speech by assistive technologies.
How to Fix: Setting the dir
Attribute
To ensure compliance with Success Criterion 3.1.2, any text in the following languages
should be accompanied by a dir
attribute set to "ltr" (left-to-right):
- arc
- fa
- he
- ks
- ps
- yi
For example, if you have a paragraph in English, the HTML code should be written as follows:
<p dir="ltr">This is an English paragraph.</p>
It is essential to note that this audit focuses on the dir
attribute within
HTML elements and does not consider CSS properties. Therefore, ensure that the
dir
attribute is correctly set within the HTML markup itself.