HTML Form Attributes

HTML Form Attributes

HTML Form Attributes

  • HTML forms attribute are used to enhance the properties of HTML form elements.

  • Form attributes are the name, value, size, maxlength, readonly, disabled etc.


HTML Form Readonly Attribute

  • HTML Readonly attribute is used to make sure that the input field is read-only (it cannot be changed).

Example:
<form>
First Name: <input type="text" name="firstname" value="Shiva" readonly >
Last Name: <input type="text" name="lastname" value="Agrawal">
</form>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Form Readonly Attribute.

Run the code to see the effect.


HTML Form Disabled Attribute

  • HTML Disabled attribute is used to disable the input field.

  • By applying the disabled attribute the input field become unusable and unclickable.

  • Here unusable means, when we send the all input values(data) to the server then disabled values do not go to the server. Its only use for display purpose.

Example:
<form>
First Name: <input type="text" name="firstname" value="Dainik" disabled>
Last Name: <input type="text" name="lastname" value="Chandra">
</form>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Form Disabled Attribute.

Run the code to see the effect.




HTML Form Size Attribute

  • HTML Size attribute is used to increase or decrease the length of the input field.

Example:
<form>
First Name: <input type="text" name="firstname" size="30">
Last Name: <input type="text" name="lastname">
</form>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Form Size Attribute.

  • size="30" increase the length of the input field which is suitable to enter 30 characters.

  • Note: It does not restrit the user to enter limited number of character. More than 30 characters are also allowed.

Run the code to see the effect.


HTML Form Maxlength Attribute

  • HTML Maxlength attribute is used to define the maximum allowable length of character for an input field.

Example:
<form>
First Name: <input type="text" name="firstname" maxlength="5">
Last Name: <input type="text" name="lastname">
</form>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Form Maxlength Attribute.

  • maxlength="5" allow only 5 character in the input field. We cannot enter more than 5 character in the input field.

Run the code to see the effect.




HTML Form Attributes in Hindi

Best Use:360p or more (480p or 720p)
×

Course Menu