Skip to content

attr-quotes

Reports an attribute value that is not quoted with ": a value with no quotes (class=a), and a value in ' unless it holds a " (class='a'). In Svelte, name={expression} is not reported, because the braces are the syntax.

An unquoted value ends at the first space or >, so a later edit that adds a word to the value changes the markup. One quote style keeps the files uniform and the diffs small.

To fix, quote the value with ".

Reported
...
<html lang="en">
<head><title>x</title></head>
<body>
<P CLASS="a" id = "b" title='c' data-x=d>x</P>
...
<p style="display: none">ok</p>
...
angular:
lint:
rules:
attr-quotes: warn # off (default), warn, error
html:
lint:
rules:
attr-quotes: warn # off (default), warn, error
svelte:
lint:
rules:
attr-quotes: warn # off (default), warn, error
vue:
lint:
rules:
attr-quotes: warn # off (default), warn, error

Enabled by the presets: html/html-validate-recommended, html/htmlhint, html/html-eslint-recommended, html/eslint-plugin-vue-recommended.

Suppress one line with sudsy-disable-next-line attr-quotes 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
eslint-plugin-svelte html-quotes full
eslint-plugin-vue html-quotes full
html-eslint quotes partial a single-quoted value that holds a double quote is allowed; unquoted values are reported
html-validate attr-quotes partial the auto style only, without the style and unquoted options
htmlhint attr-value-double-quotes partial a single-quoted value that holds a double quote is allowed