Suppose we have two divs
<div class="one"> <div class="two"></div> </div> How correctly to specify styles for div two? I have seen several ways and still do not know which one is correct.
.one.two{} .one .two{} .one > .two{} Suppose we have two divs
<div class="one"> <div class="two"></div> </div> How correctly to specify styles for div two? I have seen several ways and still do not know which one is correct.
.one.two{} .one .two{} .one > .two{} in such a situation, it is best to point to the direct style .two{} or in extreme cases .one .two{} or .one > .two{} .
This is not true .one.two{} - this is appropriate for the situation <div class="one two"></div>
<div class="one two"></div> , if there is nesting, the styles will not work.<div class="two"></div> that are inside <div class="one"></div> any nested works<div class="two"></div> that are descendants of <div class="one"></div>Source: https://ru.stackoverflow.com/questions/830105/
All Articles
.two,.one .two,.one > .two, the difference is only in the weight of the selectors. Article - css.yoksel.ru/specifity - HamSter