The dirname Attribute

The Current State of HTML5 Forms

<input type="text" name="foo" dirname="foo.dir">
<input type="submit">

Live Demo

Text input

 


Firefox
29-

Safari
6+

Safari
iOS 6+

Chrome
16+

Opera
10.6+

IE
11-

Android
4.4+

The Low Down

The dirname attribute enables the submission of the directionality of the form control along with the value of the form control on form submission.

  • When the user submits the form, the user agent will include two fields, the name / value pair and the dirname / direction. In the above example, the form will submit foo=bar&foo.dir=ltr if we entered bar as the value.
  • If the user manually switches to a right-to-left writing direction and enters something in Arabic, Hebrew or other, the value of foo.dir will be rtl.
  • The dirname attribute is only relevant for the text and search input types, and for <textarea>.

Our Cookie Policy and Privacy Policy outline how we use cookies to help personalize content, tailor and measure our marketing, and improve your user experience. I agree to use of cookies for these purposes.