Some HTML attributes allow a short list of values rather than any free-form text. The dir attribute is one of them. Choosing the right value helps the browser know how to handle your content.
Available values
| Value | Meaning |
|---|---|
ltr | Read left to right |
rtl | Read right to left |
auto | Infer direction from the content |
A page example
<p dir="ltr">English text runs from left to right.</p>
<p dir="rtl">مرحبا بالعالم</p>
<p dir="auto">User-generated message.</p>
What each choice changes
Read the HTML one element at a time. Find the dir value and compare it with the table. These are behavior or presentation hints, not ordinary words displayed on the page.
The dir attribute controls directional layout; it does not translate text or change the document language.
How to choose
Choose the simplest value that matches what your page needs. Test in a current browser, and consider keyboard use and accessibility if this attribute affects what users can reach or edit.
Practice
Copy the example and try another allowed value. After each change, refresh the page and inspect both what is visible and what is available to keyboard and screen-reader users.
Common Beginner Mistakes
- The dir attribute controls directional layout; it does not translate text or change the document language.
- Making up an attribute value and assuming the browser understands it.
- Confusing visible formatting with a control that genuinely changes behavior.
Key Takeaways
dirsupports the documented values shown above.- The dir attribute controls directional layout; it does not translate text or change the document language.
- Test the result in the browser rather than judging only from the source.