HTML dirname Attribute

HTML dirname Attribute: This attribute helps to enable the text direction of the given input and textarea field by submission of the form. It also comes with the extension of “.dir“. The dirname attribute is not supported in HTML 4. It was added newly to HTML 5.

HTML dirname Attribute

The HTML dirname attribute can applied to the <input> and <textarea> elements.

Syntax: <input name=”myname” dirname=”myname.dir”>

Browser Support

The HTML dirname attribute is supported by the following browsers:

  • Chrome
  • Safari
  • Firefox
  • Opera
  • Internet Explorer

Example: for <input> element

<!DOCTYPE html> 

    h1 { 
      color: green; 


  <form action="/action_page.php"> 
    HTML | dirname attribute 
  First name: 
    <input type="text"
    <input type="submit"

  <p>After the Submission of the form, 
  the text direction of the input field 
  will also be submitted. 




HTML dirname attribute

Example: for <textarea> element

<!DOCTYPE html>
<form action="/action_page.php">
  <textarea name="explanation"dirname="explanation.dir"></textarea>
  <input type="submit" value="Submit">
<p>When the form is being submitted, the text direction of the textarea will also be submitted.</p>


HTML dirname textarea element