Ensure required attributes are set

Rule ID:
element-required-attributes
Category:
Content model
Standards:
  • HTML5

Ensures required attributes are present but may be empty. Use attribute-allowed-values rule to disallow certain values.

The requirements comes from the element metadata:

{
  "img": {
    "attributes": {
      "src": {
        "required": true
      }
    }
  }
}

Rule details

Examples of incorrect code for this rule:

<img>
error: <img> is missing required "src" attribute (element-required-attributes) at inline:1:2:
> 1 | <img>
    |  ^^^


1 error found.

Examples of correct code for this rule:

<img src="cat.gif">