The dirname attribute is used to submit the text direction of an input field along with the form data. It is useful for supporting languages written from right to left or left to right.
- Sends the text direction (ltr or rtl) with the form submission.
- Commonly used with text and search input fields.
- Helps in handling multilingual form data correctly.
Syntax:
<input name="myname" dirname="myname.dir">Attribute Values:
- name.dir It specify that the Text direction of the input field will be submitted.
Example: Illustrates the use of dirname attribute in input Element.
<!DOCTYPE html>
<html>
<head>
<title>
</title>
<style>
h1 {
color: green;
}
</style>
</head>
<body>
<form>
<h1>
GeeksforGeeks
</h1>
<h2>
HTML | Input dirname attribute
</h2> First name:
<input type="text"
name="fname"
dirname="fname.dir">
<input type="submit"
value="Submit">
</form>
<p>
After the Submission of the form,
the text direction of the input field
will also be submitted.
</p>
</body>
</html>