Back to Freecodecamp

The Cascade of CSS Lesson C

curriculum/challenges/english/blocks/top-learn-css-specificity/6489cb0b82cf2e4f86f03ae3.md

latest710 B
Original Source

--description--

Let’s take a look at a few quick examples to visualize how specificity works. Consider the following HTML and CSS code:

html
<!-- index.html -->

<div class="main">
  <div class="list subsection"></div>
</div>
css
/* rule 1 */
.subsection {
  color: blue;
}

/* rule 2 */
.main .list {
  color: red;
}

In the example above, both rules are using only class selectors, but rule 2 is more specific because it is using more class selectors.

--questions--

--text--

Based on the given HTML and CSS code, which color would the <div class="list subsection"></div> element be rendered as?

--answers--

blue


red


purple


black

--video-solution--

2