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 |
In wordpress TwentyThirteen theme i found this styling
[class*="content"]:before
It is used to clear the float
but i don’t understand this type of styling does any one know how it works.
what’s that [ ] signifies plz expalin the syntax
I think it’s pointing to any element with a class that begins with (*=) the word “content.”
I think it’s pointing to any element with a class name that contains the word “content”, like content-wrap
This selector [class*=”content”] selects all elements that have a class attribute value that contains content. For example
1 – hello-content
2 – content-hello
3 – hellocontenthello
We can use [class$=”content”] to select elements that have a class attribute value that ends with content. For example
1 – hello-content
We can also use [class^=”content”] to select elements that have a class attribute value that begins with content. For example
1 – content-hello
>
rmniytrlykkleryklklernyl