Skip to content

string-quotes ​

Specify single or double quotes around strings.

css
a[id="foo"] { content: "x"; }
/**  ↑   ↑             ↑ ↑
 * These quotes and these quotes */

Quotes within comments are ignored.

css
/* "This is fine" */
/* 'And this is also fine' */

The rule passes over @charset, whose spelling Stylelint's at-charset-rule-no-invalid rule judges; a CSS file holding one gets a warning asking for that rule where the configuration leaves it off.

The fix option can automatically fix most of the problems reported by this rule.

The message secondary option can accept the arguments of this rule.

Options ​

string: "single"|"double"

"single" ​

Strings must always be wrapped with single quotes.

The following patterns are considered problems:

css
a { content: "x"; }
css
a[id="foo"] {}

The following patterns are not considered problems:

css
a { content: 'x'; }
css
a[id='foo'] {}
css
a { content: "x'y'z"; }

"double" ​

Strings must always be wrapped with double quotes.

The following patterns are considered problems:

css
a { content: 'x'; }
css
a[id='foo'] {}

The following patterns are not considered problems:

css
a { content: "x"; }
css
a[id="foo"] {}
css
a { content: 'x"y"z'; }

Optional secondary options ​

avoidEscape: true|false, defaults to true ​

Allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise.

For example, with "single", { "avoidEscape" : false }.

The following patterns are considered problems:

css
a { content: "x'y'z"; }
css
a[id="foo'bar'baz"] {}

The following patterns are not considered problems:

css
a { content: 'x'; }
css
a[id='foo'] {}

Released under the MIT License.