Skip to content

Disallow universal selector

nzakas edited this page Oct 24, 2011 · 2 revisions

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:

.foo * {
    background: #fff;
    color: #000;
    background: rgba(255, 255, 255, 0.5);
}

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.

Rule ID: universal-selector

Clone this wiki locally