Skip to content

attribute-allowed-values

Reports an attribute whose value is not one of the values HTML allows for it on that element, for attributes with a fixed list such as type of <button> (button, submit, reset) and method of <form>.

A browser that meets a value it does not know falls back to a default, which is not what the author wrote: type="foo" on a button makes a submit button, and the typo is never shown.

To fix, use one of the allowed values.

Reported
...
<p hidden>x</p>
<button type="send">Go</button>
<form method="put"></form>
<svg><foo></foo></svg>
</body>
</html>
angular:
lint:
rules:
attribute-allowed-values: warn # off, warn (default), error
html:
lint:
rules:
attribute-allowed-values: warn # off, warn (default), error
svelte:
lint:
rules:
attribute-allowed-values: warn # off, warn (default), error
vue:
lint:
rules:
attribute-allowed-values: warn # off, warn (default), error

Enabled by the presets: html/html-validate-standard.

Suppress one line with sudsy-disable-next-line attribute-allowed-values in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
html-eslint no-invalid-attr-value partial the values html-validate lists for an attribute; id and other pattern values are not checked
html-validate attribute-allowed-values partial values given as a pattern in the metadata (id) are not checked