Universal

Avatar of Sara Cope
Sara Cope on (Updated on )

DigitalOcean provides cloud products for every stage of your journey. Get started with $200 in free credit!

The Universal Selector is the * in CSS. Literally the asterisk character. It is essentially a type selector that matches any type. Type meaning an HTML tag like <div>, <body>, <button>, or literally any of the others.

A common use is in the universal reset, like this:

* {
  margin: 0;
  padding: 0;
}

There are times when using the universal selector is implied. For instance:

*.module {  }

is exactly the same as:

.module {  }

And in fact, the specificity of those is exactly the same, as the universal selector hold no specificity value at all.

The universal selector also is used with “universal namespaces”. It’s a bit weird, so I’ll just let this simple demo speak for itself.

Other Resources

Browser Support

Chrome Safari Firefox Opera IE Android iOS
Any Any Any Any Any Any Any