What are the new attributes provided in HTML5 for input tag?

Asked: Apr 15, 2023

Following are the new attributes provided in HTML5 for <input>

1) autofocus:

- This is a Boolean attribute.

- When present, it means that an <input> element should automatically get focus when the page is loaded.

2) form:

- This attribute specifies one or more forms an <input> element belongs to.

3) formaction:

- This attribute specifies the URL of a file that will process the input control when the form is submitted.

- This attribute is used with type="submit" and type="image".

- It overrides the action attribute of the <form> element.

4) formenctype:

- This attribute specifies how the form-data should be encoded when submitting it to the server.

- It is used with type="submit" and type="image".

- It overrides the enctype attribute of the <form> element.

5) formmethod:

- It defines the HTTP method for sending form-data to the action URL.

- It is used with type="submit" and type="image".

- It overrides the method attribute of the <form> element.

6) formnovalidate:

- It is a boolean attribute.

- It specifies that the <input> element should not be validated when submitted.

- It is used with type="submit".

- It overrides the novalidate attribute of the <form> element.

7) formtarget:

- It specifies a name or a keyword that indicates where to display the response that is received after submitting the form.

- It is used with type="submit" and type="image".

8) height and width:

- It specifies the height and width of an <input> element.

- It is used only with <input type="image">

9) list:

- It refers to a <datalist> element which contains pre-defined options for an <input> element.

10) min and max:

- It specifies the minimum and maximum value for an <input> element.

- It works with the following input types: number, range, date, datetime, datetime-local, month, time and week.

11) Multiple:

- It is a boolean attribute.

- It specifies that the user is allowed to enter more than one value in the <input> element.

- It works with the following input types: email and file.

12) pattern:

- It specifies a regular expression that the <input> element's value is checked against.

- It works with the following input types: text, search, url, tel, email, and password.

13) placeholder:

- It specifies a short hint that describes the expected value of an input field.

- It works with the following input types: text, search, url, tel, email, and password.

14) required:

- It is a boolean attribute.

- It specifies that an input field must be filled out before submitting the form.

15) step:

- It specifies the legal number intervals for an <input> element.

- It works with the following input types: number, range, date, datetime, datetime-local, month, time and week.

Asked by brijesh

Answers (0)

No answers yet. Be the first to answer!