Allowed attribute values

Rule ID:
attribute-allowed-values
Category:
Content model
Standards:
  • HTML5

Validates attributes for allowed values. Enumerated string values are matched case insensitive while regular expressions are matched case sensitive unless /i is used.

Use element-required-attributes to validate presence of attributes.

The requirements comes from the element metadata:

{
  "input": {
    "attributes": {
      "type": {
        "enum": ["text", "email", "..."]
      }
    }
  }
}

Rule details

Examples of incorrect code for this rule:

<a href>...</a>
<input type="foobar">
error: Attribute "href" is missing value (attribute-allowed-values) at inline:1:4:
> 1 | <a href>...</a>
    |    ^^^^
  2 | <input type="foobar">


error: Attribute "type" has invalid value "foobar" (attribute-allowed-values) at inline:2:14:
  1 | <a href>...</a>
> 2 | <input type="foobar">
    |              ^^^^^^


2 errors found.

Examples of correct code for this rule:

<a href="page.html">...</a>
<input type="text">