I
I
Igor Petrov2017-06-20 10:50:23
css
Igor Petrov, 2017-06-20 10:50:23

Nested CSS selectors?

Trying to improve my HTML+CSS code, gradually learning BEM, I wondered how to properly organize descendant selectors?
UPD: the only correct option, apparently:

.block{
    &__header{}
    &__text{}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iBird Rose, 2017-06-20
@t3h_l3w1z

you have now described cases that can be implemented in SCSS. And a record like:

.block{
    .block__header{}
    .block__text{}
}

still recompiled to CSS like this:
.block{}
.block .block__header{}
.block .block__text{}

You can also write:
.block{
    &__header{}
    &__text{}
}

that would be more correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question