element-required-attributes
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: offhtml/html-validate-standardhtml/htmlhinthtml/html-eslint-recommended
What it does
Section titled “What it does”Reports an element that lacks an attribute it must have: lang on <html>, src on <img>, title on <iframe>, and the like.
Why it matters
Section titled “Why it matters”Each of these attributes carries something the element cannot work without: the language for screen reader pronunciation and hyphenation, the file of an image, the name of a frame.
To fix, add the attribute.
Example
Section titled “Example”<!DOCTYPE html><html><head><title>x</title></head>...<img><img src="a.png" alt=""><iframe src="a.html"></iframe>...<p hidden>x</p>...Configuration
Section titled “Configuration”angular: lint: rules: element-required-attributes: warn # off (default), warn, errorhtml: lint: rules: element-required-attributes: warn # off (default), warn, errorsvelte: lint: rules: element-required-attributes: warn # off (default), warn, errorvue: lint: rules: element-required-attributes: warn # off (default), warn, errorEnabled by the presets: html/html-validate-standard, html/htmlhint, html/html-eslint-recommended.
Suppress one line with sudsy-disable-next-line element-required-attributes in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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 | require-frame-title |
partial | reports <embed> as well as frames |
| html-eslint | require-lang |
partial | also requires the attributes of other elements that html-validate requires (src of <img>) |
| html-validate | element-required-attributes |
full | |
| htmlhint | frame-title-require |
partial | reports <iframe> and <embed> as well as frames |
| htmlhint | html-lang-require |
partial | also requires the attributes of other elements that html-validate requires (src of <img>) |