Validates usage of input attributes

Rule ID:
input-attributes
Category:
Content model
Standards:
  • HTML5

The <input> element uses the type attribute to set what type of input field it is. Depending on what type of input field it is many other attributes is allowed or disallowed.

For instance, the step attribute can be used with numerical fields but not with textual input.

This rule validates the usage of these attributes, ensuring the attributes are used only in the proper context.

See HTML5 specification for a table of attributes and types.

Rule details

Examples of incorrect code for this rule:

<input type="text" step="5">
error: Attribute "step" is not allowed on <input type="text"> (input-attributes) at inline:1:20:
> 1 | <input type="text" step="5">
    |                    ^^^^


1 error found.

Examples of correct code for this rule:

<input type="number" step="5">

Version history