Why does the universal selector * have a negative impact on browser rendering?

1

I was going to apply a CSS Reset on my website. I usually use Eric Meyer's link . But I was looking at the suggestion of Diego Eis in link that is like this:

* {
margin:0;
padding:0;
list-style:none;
vertical-align:baseline;
}

I found it cooler, simpler (of course Eric Meyer's is more complete.)

I was testing on my Visual Studio Express 2013 for Web, and Web Essentials ran a warning saying:

  

Performance: Never use the universal selector. It's a big negative   performance impact on browsers rendering.

Translating:

  

Performance: Never use the universal selector. This has a large   performance impact on browser rendering.

Why does the universal selector * cause this negative impact on browser rendering?

    
asked by anonymous 06.08.2014 / 15:01

2 answers

4

The concept that the universal selector is slow is a myth coined ten years ago when, in fact, there were performance problems, not surprisingly, because of Internet Explorer 6.

Nowadays, in modern browsers the performance impact of the universal dial is insignificant as long as you do not set rules that result in slower effects on it.

Unlike the reference article, personally, I would not define CSS3 effects in the universal selector. Not only because I vehemently doubt that ALL elements would REALLY need that particular effect, but also because I favor reusable generic classes present in CSS frameworks like Bootstrap.

Source: Article on the Telerik Blog via an answer in SOen

    
06.08.2014 / 15:13
2

The main argument against the universal selector was not so much performance, but the impact it had on property inheritance.

In practice, neither loss of performance nor inheritance problems were ever relevant enough to abolish use, because it was much quicker and more practical to use it and make a few specific definitions then including adopting stylesheets specific for the late IE6, which was already obsolete when the use of CSS2 gained strength and table-based layouts began to fall into disuse.

A template I've always adopted, recently upgraded to html5, was:

* {
  margin:0;
  padding:0;
 /* outros estilos com base no projeto */ 
}

div, article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}

a, a:link, a:visited, a:hover, a:active { 
  text-decoration:none; 
  font:inherit; 
}

li {
  list-style-type:none;
}

Even because, again, in practice, you always have to define the styles according to the project, each one specifically, and in the reset, only the elements that really can get in the way or repeat themselves in creation are inserted.     

06.08.2014 / 17:53