HTML <input> dirname Attribute

The dirname attribute on an <input> tag submits the direction, left-to-right or right-to-left, of the input field.

Example

#

A dirname attribute on an <input> element.
Submitting this form will send the text input value and its direction.




<form action="/tutorial/action.html">
  <label for="firstname">First name</label><br />
  <input type="text" id="firstname" 
         name="firstname" dirname="firstname.dir">
  <br /><br />

  <input type="submit" value="Submit">
</form>

Using dirname

The dirname attribute submits the text direction together with the value of the input element.

The name of this attribute must be the input field name followed by .dir.

This attribute helps in identifying the correct direction for an input value.

Here is a list of the languages that are written from right-to-left (rtl):

  • Arabic
  • Aramaic
  • Azeri
  • Dhivehi/Maldivian
  • Hebrew
  • Kurdish (Sorani)
  • Persian/Farsi
  • Urdu

Syntax

<input name="input-name" dirname="input-name.dir">

Values

#

Value Description
input-name.dir Submits the text direction of the input value.
Possible values are ltr (left-to-right) or rtl (right-to-left).

Browser support

Here is when dirname support started for each browser:

Chrome
1.0 Sep 2008
Firefox
Not Supported
IE/Edge
79.0 Jan 2020
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <input>
Guides