Skip to content

Commit c106d73

Browse files
author
Nicholas C. Zakas
committed
Added rule to warn when using the universal selector (fixes CSSLint#38)
1 parent cfb1f33 commit c106d73

File tree

11 files changed

+2335
-1244
lines changed

11 files changed

+2335
-1244
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Next (not yet released)
22

3+
* Add rule to warn for universal selector (fixes #38)
34
* Changed too many !important error to warning (fixes #105)
45
* Updated parser to allow parsing of CSS3 keyframes
56
* Fixed error where Rhino CLI could not read directories (fixes #106)

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ However, if the properties either have the same value or are located at differen
128128
background: rgba(255, 255, 255, 0.5);
129129
}
130130

131+
### Universal Selector
132+
133+
The universal selector (*) selects all elements and can create performance issues when used as the far-right part of a selector. For example, this type of rule is not preferable:
134+
135+
.foo * {
136+
background: #fff;
137+
color: #000;
138+
background: rgba(255, 255, 255, 0.5);
139+
}
140+
141+
This requires the browser to match all elements first, and then go up the DOM tree to find an element with a class of `.foo`. Generally, it's best to avoid using the universal selector.
142+
131143
## Contributors
132144

133145
### Creators

0 commit comments

Comments
 (0)