Could somebody please direct me to the CSS hierarchy rules concerning "concatenated classes" versus "separated classes"?
Furthermore, what are the correct terms for "concatenated classes" versus "separated classes" (I suspect that is why the documentation I am looking for remains elusive.)
For instance, in the CSS provided below, .row .second
(with a space) seems to have higher precedence than .row.second
(without a space), despite both matching 2 class attributes.
.row {
width: 150px;
background-color: lightgray;
margin: 15px;
}
section {
margin-left: 15px;
}
.row .second {
color: purple;
}
.row.second {
color: orange;
}
When applied to the following HTML, the above CSS yields this outcome: https://i.sstatic.net/acKxF.png
Why is "Stuff 2b" displayed in purple instead of orange? (In simpler terms, why does .row .second
take precedence over .row.second
in this scenario?)
<div id='outerBox'>
<div class="row">
<div class="title">
Row 1 Title
</div>
<section>
Stuff 1a
</section>
<section class='second'>
Stuff 1b
</section>
<section>
Stuff 1c
</section>
</div>
<div class="row second">
<div class="title">
Row 2 Title
</div>
<section>
Stuff 2a
</section>
<section class='second'>
Stuff 2b
</section>
<section>
Stuff 2c
</section>
</div>
<div class="row">
<div class="title">
Row 3 Title
</div>
<section>
Stuff 3a
</section>
<section class='second'>
Stuff 3b
</section>
<section>
Stuff 3c
</section>
</div>
</div>
(The CSS mentioned here is being used on the HTML provided above in JSFiddle on Chrome for MacOS.)