CSS value '*'

Possible duplicate:
css: value * mark

What does * do in css? I saw here the code that contained it:

 .center-wrapper{ text-align: center; } .center-wrapper * { margin: 0 auto; } 

It's a typo?

+6
source share
6 answers

* means ALL.

In this case, it will be ALL elements in the .center-wrapper

+14
source

This is a wildcard; it matches each element. Thus, in your example, this means that each element that is a descendant of the elements has a class of "center-wrapper".

According to W3C official docs, it is called a universal selector, see http://www.w3.org/TR/css3-selectors/#universal-selector :

The universal selector, written as the Name assigned by CSS (CSS3NAMESPACE) with an asterisk (* U + 002A) as the local name, is the name of any element type.

+4
source

* means that the styles assigned to it should be applied to the whole page. This is not a typo.

0
source
  • means everthing: every tag / element in a document.

In this case, the .center-wrapper * all under each element with the center wrapper class.

0
source

This means that it will select all the elements inside this part of the DOM.

0
source

* - universal selector. .center-wrapper * select all .center-wrapper descendant .center-wrapper .

0
source

Source: https://habr.com/ru/post/890759/


All Articles