html tutorial - dirname Attribute in HTML - html5 - html code - html form



Dirname attribute in html

Learn html - html tutorial - Dirname attribute in html - html examples - html programs

  • The dirname attribute enables the submission of the text direction of the input field or textarea.
  • The dirname attribute’s value is always the name of the input field/text area, followed by “.dir”.
  • The dirname attribute will apply to the following elements. The elements are <input> and <textarea>.

Syntax for <dirname> attribute:

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

Differences between HTML 4.01 and HTML5

HTML 4.01

  • The dirname attribute is not supported in HTML 4.

HTML5

  • The dirname attribute is added newly in HTML 5.

Applies to:

Elements Attribute
<textarea> dirname
<input> dirname

Attribute Value of dirname in HTML:

Value Description
myname.dir Defines that the text direction of the form or the textarea will be submitted.

Sample coding for dirname attribute:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy HTML dirname Attribute</title>
    </head>
    <body>
        <form action="dirname.html">
            Enter the text: <input type="text" name="txtname" dirname="txtname.dir">
            <input type="submit" value="Submit">
        </form>
    </body>
</html>

Code Explanation for dirname attribute in HTML:

dirname Attribute Code Explanation

  1. Form to define the input element
  2. The dirname attribute’s value is always the name of the input field, followed by “.dir”.

Output of dirname attribute in HTML

dirname Attribute Output

  1. Enter the any text (here we mention wikitechy in the text box) in the text box and click submit button.
  2. After clicking the submit button the text name and the dirname of the text is displayed in the address bar as txtname=wikitechy&txtname.dir=ltr. The ltr is defined as left to right that is the direction of the text is left to right.

Browser Support for dirname attribute in HTML:

Yes No No Yes Yes

Related Searches to dirname Attribute in html