Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Basics (2014) Understanding Values and Units Styling the Intro Paragraph

Colin van Wyk
Colin van Wyk
8,258 Points

how do I create a new rule to target the span element in .intro? Class Selectors?

I feel silly even asking this, but I'm so stuck on this that I can't seem to think straight anymore... I get that I'm supposed to make the "breathtaking attractions" bolder and italic, but how do I select the <span> element inside? I thought I'd add a class selector like the <span> element in the header, but for the life of me I can't figure out what I'm doing wrong.

index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lake Tahoe</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body> 
    <header id="top" class="main-header">
      <span class="title">Journey Through the Sierra Nevada Mountains</span>
      <h1>Lake Tahoe, California</h1>
    </header>
    <div class="primary-content t-border">
      <p class="intro">
        Lake Tahoe is one of the most <span class="highlight">breathtaking attractions</span> located in California. It's home to a number of ski resorts, summer outdoor recreation, and tourist attractions. Snow and skiing are a significant part of the area's reputation.
      </p>
      <a href="#more">Find out more</a>
    </div>
    <footer class="main-footer">
      <p>All rights reserved to the state of <a href="#">California</a>.</p>
      <a href="#top">Back to top &raquo;</a>
    </footer>
  </body>
</html>
style.css
/* Complete the challenge by writing CSS below */
.intro {
  font-size: 1.25em;
  line-height: 1.6;  
}

.highlight {
  font-weight: bold;
  font-style: italic;
}

1 Answer

andren
andren
28,558 Points

Technically adding a class like you have done does work, but it bypasses the lesson that the challenge is actually set up to teach you. That's why its not accepted as an answer.

The point of this challenge is to test your memory of the Descendant Selector that was introduced back in the Basic Selectors section of the course.

The Descendant Selector allows you to target elements nested within other elements without relying on adding classes to everything.

The way the Descendant Selector works is that you simply specify multiple tag/class/id selectors separated by a space, and then the last element you specify will be selected but only if it is nested within the other elements specified.

So the solution is simply to use the intro class selector and then specify the span tag selector after it like this:

.intro span {
  font-weight: bold;
  font-style: italic;
}
Colin van Wyk
Colin van Wyk
8,258 Points

Ah! I see! Thank you for clearing that up for me! You are correct, thanks for your effort in replying to my question, it is much appreciated! :)