Skip to main content
HTML Validation

Bad value “” for attribute “dir” on element “input”.

About This HTML Issue

The dir attribute on an <input> element is set to an empty string, and dir only accepts ltr, rtl or auto.

dir sets the direction of the text inside the field. The HTML standard treats an empty or unknown value as if the attribute were missing, so the input takes its direction from its parent and dir="" changes nothing. A bare dir with no value counts as empty too, and gets the same error.

A template that fills dir from the page language can print it empty for left-to-right languages. If the field should follow the page direction, remove the attribute. If people may type in a right-to-left script such as Arabic or Hebrew, which is common in search boxes, use dir="auto" and the browser sets the direction from the first letter typed. Add dirname when the server needs that direction too. The form then submits it as an extra field, such as q.dir=rtl.

Invalid example

<form action="/search">
  <input type="search" name="q" aria-label="Search" dir="">
</form>

Valid example

Remove the attribute so the field follows the page direction:

<form action="/search">
  <input type="search" name="q" aria-label="Search">
</form>

Or let the field follow the text the user types:

<form action="/search">
  <input type="search" name="q" aria-label="Search" dir="auto" dirname="q.dir">
</form>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

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.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries