UNPKG

1.91 kBMarkdownView Raw
1# string-quotes
2
3Specify single or double quotes around strings.
4
5```css
6a[id="foo"] { content: "x"; }
7/** ↑ ↑ ↑ ↑
8 * These quotes and these quotes */
9```
10
11Quotes within comments are ignored.
12
13
14```css
15/* "This is fine" */
16/* 'And this is also fine' */
17```
18
19Single quotes in a charset @-rule are ignored as using single quotes in this context is incorrect according the [CSS specification](https://www.w3.org/TR/CSS2/syndata.html#x57).
20
21```css
22@charset "utf-8"
23/* fine regardless of configuration */
24```
25
26The `--fix` option on the [command line](../../../docs/user-guide/cli.md#autofixing-errors) can automatically fix most of the problems reported by this rule.
27
28## Options
29
30`string`: `"single"|"double"`
31
32### `"single"`
33
34Strings *must always* be wrapped with single quotes.
35
36The following patterns are considered violations:
37
38```css
39a { content: "x"; }
40```
41
42```css
43a[id="foo"] {}
44```
45
46The following patterns are *not* considered violations:
47
48```css
49a { content: 'x'; }
50```
51
52```css
53a[id='foo'] {}
54```
55
56```css
57a { content: "x'y'z"; }
58```
59
60### `"double"`
61
62Strings *must always* be wrapped with double quotes.
63
64The following patterns are considered violations:
65
66```css
67a { content: 'x'; }
68```
69
70```css
71a[id='foo'] {}
72```
73
74The following patterns are *not* considered violations:
75
76```css
77a { content: "x"; }
78```
79
80```css
81a[id="foo"] {}
82```
83
84```css
85a { content: 'x"y"z'; }
86```
87
88## Optional secondary options
89
90### `avoidEscape`: `true|false`, defaults to `true`
91
92Allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise.
93
94For example, with `"single", { "avoidEscape" : false }`.
95
96The following patterns are considered violations:
97
98```css
99a { content: "x'y'z"; }
100```
101
102```css
103a[id="foo'bar'baz"] {}
104```
105
106The following patterns are *not* considered violations:
107
108```css
109a { content: 'x'; }
110```
111
112```css
113a[id='foo'] {}
114```