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 Selector Question (Typography)

I followed through the video and the CSS styling in the lead class was not showing up. Changing the selectors to p.lead solved the problem, but I would like to know why it works in the video with just "lead" declared as the class.

2 Answers

Hello! :)

So, p.lead would indicate that you have selected to style all paragraphs <p> that have the class="lead" within it's tag.

p.lead {

}

Hope this helps!

I would have to see your code but is sounds like you were trying to select and style a class names lead. If that's the case you would need to place a period before the word lead

.lead {
  (your code here)
}

If you forget the period you are try select an html element named lead, which of course it won't find unless you actually use a tag named lead.

p.lead worked because as James said you were selecting all paragraphs with a class of lead.

so to sum up p.lead and .lead should both give you the same results provided only that paragraph has a class of lead.

hope that helps!

I began my selector declaration as you've written (with the leading .). It seems to be working with the hack I used but I was just curious as to why it might be the case. All my other class selectors are working just fine and there's no typos between the html and css.

Thanks again.