What is the difference between these two classes?

I don't know how they differ in css

something { //some properties } something >.somethingelse { // something else properties } 

and

 something { //some properties } something .somethingelse { // something else properties } 

I do not know why in the second case there is such a > . Should there also be < to use?

+4
source share
3 answers

> indicates that the direct children of somethingelse are in something . Otherwise, the descendants will be found at all levels.

So using the following example:

 <div class="something"> <div class="somethingelse"> <div class="somethingelse"> </div> </div> </div> 

For example > only the external somethingelse div takes effect. For an example without > both divs will have the applicable style.

< may mean the parent selector (i.e. apply the style to the direct parent of the corresponding class). I don't know about this yet, but here's an interesting post: csstricks here .

+7
source

> selects any element with a class .somethingelse , which is a child of an element with a class .something .

The second CSS selector will select any descendants of the element with the .something class. That is, children, children of children, etc.

+3
source

> selects direct descendants of something that have the .somethingelse class

There is currently no parent ( < ) selector in CSS

0
source

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


All Articles