Does the star selector in CSS affect page rendering performance?
Are there any caveats using it?
* {
margin:0;
padding:0;
}
Does the star selector in CSS affect page rendering performance?
Are there any caveats using it?
* {
margin:0;
padding:0;
}
Since I'm using the exact same rule in every of my projects and none have serious perfomance issues, I'd say: No, not as far as I know.
When it comes to performance, Steve Souders is the man:
Shameless quote from one of the reports:
[bold emphasis mine]
One view is that it's not so much that the * is a performance problem, it's that good old favourite - there's an IE issue with it. It affects IE 5, 5.5 and 6 as well as Macintosh variants. Basically, there is something called the HTML star selector bug which applies as follows:
This should be interpreted as no element match because html is root and cannot be a child element. IE interprets this as html.
Again, should match to no element because body cannot be a grandchild element - even though it is a child element of HTML. IE interprets this as * body.
This should match no element, but IE interprets this as html body.
The performance side is usually treated that applying * only means that the style applies to every element in a page. I rarely find that this is an issue in its own right - the point at which it would become an issue means that you've probably got way too much markup in there anyway. Similarly, as it applies to everything, it means you need to increase your code to cope with elements that shouldn't have that style. As with everything else, it's up to you to decide what the tradeoffs and balance should be.
For some properties using
*
can produce unexpected results.Now given
<li><i>text</i></li>
, the text will be blue!