Nested Elements

Hi, guys.

I have a question about the exercise “Nested elements” in learning CSS (https://www.codecademy.com/courses/learn-css/lessons/css-setup-selectors/exercises/nested-elements).

We were supposed to edit h5 elements within the class “description” and that is the solution:

< h5>Top Attractions< /h5>
< ul class=“description”>
< li>Museums< /li>
< li>Bike Tours< /li>
< li>Historical Monuments< /li>
< /ul>
.description h5 {
color: teal;
}

My question is: since the tag h5 is not nested within ul, how come it works? Wasn’t it supposed to work only with the < li> in this case? Or maybe they just have to be inside the same < div>?!

If i look at this project, i see the description class on the div:

  <h2 class="destination">1. Florence, Italy</h2>
  <div class="description">A city-size shrine to the Renaissance, Florence offers frescoes, sculptures, churches, palaces, and other monuments from the richest cultural flowering the world has known. Names from its dazzling historical pastDante, Michelangelo, Galileo, Machiavelliare some of the most resonant of the medieval age. <a href="http://travel.nationalgeographic.com/travel/city-guides/florence-italy/" target="_blank">Learn More</a>.
    <h5>Top Attractions</h5>
    <ul>
      <li>Museums</li>
      <li>Bike Tours</li>
      <li>Historical Monuments</li>
    </ul>
  </div>

not the unordered list.

In your case, h5 isn’t a child of .description, so no styling would be applied

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.