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 trialCarlos Serrano
3,351 PointsSetting <p> attributes into divs
Hello. Can anyone tell me how to make the <p> element inside the divs a different color than the one outside for this exercise? Thank you
4 Answers
Daniel Aguirre
4,498 PointsUse Span on the HTML ex: <span>Hi world</span>
is easier
Andrew McCormick
17,730 PointsCarlos Serrano , posting your code or an example of your html code would help.
It sounds like you just need to have more specific selectors.
Example:
<h1>This would be green</h1>
<div id="content">
<h1>This would be red</h1>
</div>
h1 {
color: green;
}
#content h1 {
color: red;
}
Carlos Serrano
3,351 PointsThank you guys. I thought discussions were related to each lesson by default. Sorry for not being more specific. I was referring to the Pseudo-Classes-nth-of-type and:only-of-type lesson under Web Design / Advanced Selectors. On 5:05 the instructor is adding text to some previously created divs. I was wondering how to select the text "inside the divs" only and add for example a different color "just" to this element. Thank you
Andrew McCormick
17,730 PointsOh. you are looking for div > p:only-of-type {}
See Updated Example Codepen
Carlos Serrano
3,351 PointsThank you Andrew. This is exactly what I needed.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsCould you be more specific please?