UNPKG

2.6 kBMarkdownView Raw
1# selector-pseudo-element-colon-notation
2
3Specify single or double colon notation for applicable pseudo-elements.
4
5<!-- prettier-ignore -->
6```css
7 a::before {}
8/** ↑
9 * This notation */
10```
11
12The `::` notation was chosen for _pseudo-elements_ to establish a discrimination between _pseudo-classes_ (which subclass existing elements) and _pseudo-elements_ (which are elements not represented in the document tree).
13
14However, for compatibility with existing style sheets, user agents also accept the previous one-colon notation for _pseudo-elements_ introduced in CSS levels 1 and 2 (namely, `:first-line`, `:first-letter`, `:before` and `:after`).
15
16The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
17
18## Options
19
20`string`: `"single"|"double"`
21
22### `"single"`
23
24Applicable pseudo-elements _must always_ use the single colon notation.
25
26The following patterns are considered violations:
27
28<!-- prettier-ignore -->
29```css
30a::before { color: pink; }
31```
32
33<!-- prettier-ignore -->
34```css
35a::after { color: pink; }
36```
37
38<!-- prettier-ignore -->
39```css
40a::first-letter { color: pink; }
41```
42
43<!-- prettier-ignore -->
44```css
45a::first-line { color: pink; }
46```
47
48The following patterns are _not_ considered violations:
49
50<!-- prettier-ignore -->
51```css
52a:before { color: pink; }
53```
54
55<!-- prettier-ignore -->
56```css
57a:after { color: pink; }
58```
59
60<!-- prettier-ignore -->
61```css
62a:first-letter { color: pink; }
63```
64
65<!-- prettier-ignore -->
66```css
67a:first-line { color: pink; }
68```
69
70<!-- prettier-ignore -->
71```css
72input::placeholder { color: pink; }
73```
74
75<!-- prettier-ignore -->
76```css
77li::marker { font-variant-numeric: tabular-nums; }
78```
79
80### `"double"`
81
82Applicable pseudo-elements _must always_ use the double colon notation.
83
84The following patterns are considered violations:
85
86<!-- prettier-ignore -->
87```css
88a:before { color: pink; }
89```
90
91<!-- prettier-ignore -->
92```css
93a:after { color: pink; }
94```
95
96<!-- prettier-ignore -->
97```css
98a:first-letter { color: pink; }
99```
100
101<!-- prettier-ignore -->
102```css
103a:first-line { color: pink; }
104```
105
106The following patterns are _not_ considered violations:
107
108<!-- prettier-ignore -->
109```css
110a::before { color: pink; }
111```
112
113<!-- prettier-ignore -->
114```css
115a::after { color: pink; }
116```
117
118<!-- prettier-ignore -->
119```css
120a::first-letter { color: pink; }
121```
122
123<!-- prettier-ignore -->
124```css
125a::first-line { color: pink; }
126```
127
128<!-- prettier-ignore -->
129```css
130input::placeholder { color: pink; }
131```
132
133<!-- prettier-ignore -->
134```css
135li::marker { font-variant-numeric: tabular-nums; }
136```