* {
box-sizing: border-box;
}
a {
color: #3488C9;
text-decoration: underline;
}
.wrapper {
display: inline-block;
width: 100%;
}
[class*="accent-"] {
padding: 20px;
width: 100%;
display: inline-block;
}
[class*="accent-"] p, [class*="accent-"] b, [class*="accent-"] strong, [class*="accent-"] i, [class*="accent-"] em, [class*="accent-"] blockquote,
[class*="accent-"] h1, [class*="accent-"] h2, [class*="accent-"] h3, [class*="accent-"] h4, [class*="accent-"] h5, [class*="accent-"] h6,
[class*="accent-"] ul, [class*="accent-"] ol, [class*="accent-"] li, [class*="accent-"] a {
color: unset;
}
.accent-1 {
background-color: #333;
color: white;
--anchor-color: white;
}
.accent-2 {
background-color: #ccc;
color: black;
--anchor-color: #3488C9;
}
.accent-3 {
background-color: salmon;
color: black;
--anchor-color: white;
}
.accent-4 {
background-color: #2A4D68;
color: white;
--anchor-color: white;
}
.accent-5 {
background-color: #fff;
color: black;
--anchor-color: #3488C9;
}
.accent-1 a, .accent-2 a, .accent-3 a, .accent-4 a, .accent-5 a {
color: var(--anchor-color);
}
[class*="col-"] {
float: left;
}
.col-2 {
width: 50%;
}
.col-3 {
width: 33.3333%;
}
.col-4 {
width: 25%;
}
[class*="correct"] {
color: #fff !important;
padding: 3px 4px;
border-radius: 3px;
display: inline;
font-size: 12px;
font-weight: normal;
vertical-align: middle;
}
.correct {
background-color: green;
}
.incorrect {
background-color: red;
}
em {
font-size: 13px;
opacity: 0.8;
}
<section class="wrapper">
<div class="accent-1">
<h3>Section A: Accent 1 <strong class="correct">CORRECT</strong> </h3>
<p>In this section, text should be white and <a>links</a> should be <a>white</a>.</p>
<p><em>All the styles in this section are correct because the parent div has a class of .accent-1, which is output before the rest of the accent styles, allowing them to override the parent's styles</em></p>
<section class="wrapper">
<div class="accent-2">
<h3>Section A: Accent 2 <strong class="correct">CORRECT</strong> </h3>
<p>In this section, text should be black and <a>links</a> should be <a>blue</a>.</p>
<section class="wrapper">
<div class="accent-3">
<h3>Section A: Accent 3 <strong class="correct">CORRECT</strong> </h3>
<p>In this section, text should be black and <a>links</a> should be <a>white</a>.</p>
</div>
</section>
</div>
</section>
</div>
</section>
<section class="wrapper">
<div class="accent-4">
<h3>Section B: Accent 4 <strong class="correct">CORRECT</strong></h3>
<p>In this section, text should be white and <a>links</a> should be <a>white</a>.</p>
<section class="wrapper">
<div class="accent-2">
<h3>Section B: Accent 2 <strong class="correct">CORRECT</strong></h3>
<p>In this section, text should be black and <a>links</a> should be <a>blue</a>.</p>
<p><em>This is incorrect because blue .accent-4 comes after light-grey .accent-2 in the stylesheet and the elements inside this section are also children of a blue .accent-4 section (SectionB:accent-4)</em></p>
<section class="wrapper">
<div class="accent-1">
<h3>Section B: Accent 3 <strong class="correct">CORRECT</strong></h3>
<p>In this section, text should be white and <a>links</a> should be <a>white</a>.</p>
<p><em>This is only correct because the colors for the blue parent section (SectionB:Accent4) are being applied and are the same.</em></p>
</div>
</section>
</div>
</section>
</div>
</section>
<section class="wrapper">
<div class="accent-1">
<h3>Section C: Accent 1 <strong class="correct">CORRECT</strong> </h3>
<p>In this section, text should be white and <a>links</a> should be <a>white</a>.</p>
<p><em>All the styles in this section are correct because the parent div has a class of .accent-1, which is output before the rest of the accent styles, allowing them to override the parent's styles</em></p>
<section class="wrapper col-4">
<div class="accent-5">
<h3>Section C: Accent 5</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be black and <a>links</a> should be <a>blue</a>.</p>
</div>
</section>
<section class="wrapper col-4">
<div class="accent-2">
<h3>Section C: Accent 2</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be black and <a>links</a> should be <a>blue</a>.</p>
</div>
</section>
<section class="wrapper col-4">
<div class="accent-3">
<h3>Section C: Accent 3</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be black and <a>links</a> should be <a>white</a>.</p>
</div>
</section>
<section class="wrapper col-4">
<div class="accent-4">
<h3>Section 3: Accent 4</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be white and <a>links</a> should be <a>white</a>.</p>
</div>
</section>
</div>
</section>
<section class="wrapper">
<div class="accent-4">
<h3>Section D: Accent 4 <strong class="correct">CORRECT</strong></h3>
<p>In this section, text should be black and <a>links</a> should be <a>white</a>.</p>
<section class="wrapper col-4">
<div class="accent-5">
<h3>Section D: Accent 5</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be black and <a>links</a> should be <a>blue</a>.</p>
<p><em>This is correct because the styles for .accent-5 are output after the styles for the parent div with .accent-4 class</em></p>
</div>
</section>
<section class="wrapper col-4">
<div class="accent-3">
<h3>Section D: Accent 3</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be black and <a>links</a> should be <a>white</a>.</p>
</div>
</section>
<section class="wrapper col-4">
<div class="accent-2">
<h3>Section D: Accent 2</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be black and <a>links</a> should be <a>blue</a>.</p>
<p><em>Once again, this is incorrect because the styles for the .accent-2 class are output before the styles for the .accent-4 class of the parent wrapper.</em></p>
</div>
</section>
<section class="wrapper col-4">
<div class="accent-1">
<h3>Section D: Accent 1</h3>
<strong class="correct">CORRECT</strong>
<p>In this section, text should be white and <a>links</a> should be <a>white</a>.</p>
<p><em>And again, this is only correct because the foreground colors for .accent-4 happen to be the same as .accent-1</em></p>
</div>
</section>
</div>
</section>