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

Raul Perez
Raul Perez
5,846 Points

Targeting a nested element

Not sure about how to target a nested element. Please review my code that is attached.

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="intr">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;
}

.intr, .intro {
  font-weight: bold;
  font-style: italic;
}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing really well here and clearly know how to write your CSS rules. It's fairly common that people experience more difficulty learning how to use selectors. But since you're doing so well here, I'm not going to give you an explicit answer, but rather something that is very similar.

Let's say for example that I have a <div> element with the class "my-div". Inside that div, I have an <h1> element. The HTML would look something like this:

<div class="my-div">
  <h1>This is my div element!</h1>
</div>

Let's also assume that there are more than one h1 elements on the page, but I want to target just the h1 elements that live inside a container with that class. I'm going to turn the text red. I could use a selector like this in my CSS:

.my-div h1 {
   color: red;
}

That's it! First we say the class, and then the name of the element. This will target all h1 elements that reside in any container with the class "my-div".

I think you can get it with this example, but let me know if you're still stuck! :sparkles: