Why can’t you call CSS "pasted" classes

Asked

Viewed 28 times

1

Why can’t I call classes "glued", like this:

.div1.div2.div3 {
   blablabla;
}

That’s the only way I can do it:

.div1 .div2 .div3{
   blablabla
}

I’d like to know the difference.

1 answer

3


At first:

.div1.div2.div3 {
   blablabla;
}

You are selecting an element that has all three classes, such as:

<div class="div1 div2 div3"></div>

In the second case you are working with the following structure:

<div class="div1">
  <div class="div2">
    <div class="div3">
      ...
    </div>
  </div>
</div>

That is div1 > div2 > div3, in relation to inheritance. Thus selecting the element .div3 son of the element .div2 son of the element .div1.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.