HTML Guides for dir
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The dir attribute cannot be an empty string — it must be one of the allowed values: ltr, rtl, or auto.
The dir attribute specifies the text directionality of an element’s content. It is a global attribute, meaning it can be used on any HTML element. When you set dir="", the validator rejects it because an empty string doesn’t convey any meaningful direction.
If you don’t need to specify a direction, simply remove the dir attribute entirely. The element will naturally inherit the directionality from its parent. If you want the browser to determine the direction based on the text content, use dir="auto".
Invalid Example
<span dir="">Some text</span>
Valid Examples
<!-- Remove the attribute to inherit direction from the parent -->
<span>Some text</span>
<!-- Or explicitly set a valid direction -->
<span dir="ltr">Some text</span>
<!-- Or let the browser decide based on content -->
<span dir="auto">Some text</span>
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries