1 | # alpha-value-notation
|
2 |
|
3 | Specify percentage or number notation for alpha-values.
|
4 |
|
5 |
|
6 | ```css
|
7 | a { color: rgb(0 0 0 / 0.5) }
|
8 | /** ↑
|
9 | * This notation */
|
10 | ```
|
11 |
|
12 | The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
|
13 |
|
14 | ## Options
|
15 |
|
16 | `string`: `"number"|"percentage"`
|
17 |
|
18 | ### `"number"`
|
19 |
|
20 | Alpha-values _must always_ use the number notation.
|
21 |
|
22 | The following patterns are considered violations:
|
23 |
|
24 |
|
25 | ```css
|
26 | a { opacity: 50% }
|
27 | ```
|
28 |
|
29 |
|
30 | ```css
|
31 | a { color: rgb(0 0 0 / 50%) }
|
32 | ```
|
33 |
|
34 | The following patterns are _not_ considered violations:
|
35 |
|
36 |
|
37 | ```css
|
38 | a { opacity: 0.5 }
|
39 | ```
|
40 |
|
41 |
|
42 | ```css
|
43 | a { color: rgb(0 0 0 / 0.5) }
|
44 | ```
|
45 |
|
46 | ### `"percentage"`
|
47 |
|
48 | Alpha-values _must always_ use percentage notation.
|
49 |
|
50 | The following patterns are considered violations:
|
51 |
|
52 |
|
53 | ```css
|
54 | a { opacity: 0.5 }
|
55 | ```
|
56 |
|
57 |
|
58 | ```css
|
59 | a { color: rgb(0 0 0 / 0.5) }
|
60 | ```
|
61 |
|
62 | The following patterns are _not_ considered violations:
|
63 |
|
64 |
|
65 | ```css
|
66 | a { opacity: 50% }
|
67 | ```
|
68 |
|
69 |
|
70 | ```css
|
71 | a { color: rgb(0 0 0 / 50%) }
|
72 | ```
|
73 |
|
74 | ## Optional secondary options
|
75 |
|
76 | ### `exceptProperties: ["/regex/", /regex/, "string"]`
|
77 |
|
78 | Reverse the primary option for matching properties.
|
79 |
|
80 | For example with `"percentage"`.
|
81 |
|
82 | Given:
|
83 |
|
84 | ```
|
85 | ["opacity"]
|
86 | ```
|
87 |
|
88 | The following patterns are considered violations:
|
89 |
|
90 |
|
91 | ```css
|
92 | a { opacity: 50% }
|
93 | ```
|
94 |
|
95 |
|
96 | ```css
|
97 | a { color: rgb(0 0 0 / 0.5) }
|
98 | ```
|
99 |
|
100 | The following patterns are _not_ considered violations:
|
101 |
|
102 |
|
103 | ```css
|
104 | a { opacity: 0.5 }
|
105 | ```
|
106 |
|
107 |
|
108 | ```css
|
109 | a { color: rgb(0 0 0 / 50%) }
|
110 | ```
|