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 trialRichard Srery
640 Pointsi don't know...
i don't know how to target the paragraph that is a descendant of the main-content class
11 Answers
Greg Kaleka
39,021 PointsHi Richard,
This is actually pretty simple. Let's break it down:
/* To target all paragraphs, you'd write a rule like this: */
p {
color: tomato;
}
/* To target the main-content class, you'll write a rule like this: */
.main-content {
display: block;
}
/* To target the paragraph that's a descendant of the main-content class, you'll write a rule like this: */
.main-content p {
color: blue;
}
To target a descendant of something else, you just write the "parent" element first (in this case the class .main-content), then the descendant (in this case paragraphs), with a space in between.
Make sense?
Chris Adamson
132,143 PointsIt's looking for the main-content selector (prefaced by the dot ',' for classes) followed by the paragraph p selector:
.main-content p {
font-weight: bold;
}
Viraj Kokane
17,531 PointsTry this It will work: .main-content p { }
Richard Srery
640 Pointsto Viraj Kokane: Bummer! i have to Make sure i'm targeting the paragraph nested inside '.main-content'.
Viraj Kokane
17,531 PointsHave you entered the given value in the task.
Richard Srery
640 Pointsi know that already
Greg Kaleka
39,021 PointsGreat! Just a reminder - these kinds of comments can go in comments instead of new answers :)
Richard Srery
640 Pointsyeah that makes sense
Richard Srery
640 Pointsto Greg: IT WORKED! You are so the best programmer and oh how did you get to be a MOD
Greg Kaleka
39,021 PointsGreat - glad you got it to work!
Treehouse reaches out to students who have some subject-matter expertise (essentially, lots of points :), and are active in the forums, and asks them to be moderators.
Cheers,
Greg
P.S. for future reference, it's better to add a comment to answers rather than posting new ones when you want to reply to someone.
Richard Srery
640 Points|:(
Viraj Kokane
17,531 PointsCSS.main-content p {
font-weight: bold;
}
Richard Srery
640 Pointsi can't do a question on a quiz "We define the universal selector with a(n) ______."
Viraj Kokane
17,531 Pointstry this: *
Viraj Kokane
17,531 PointsHave you solved the quiz ? The answer was: We define the universal selector with a(n) *_."
Richard Srery
640 Pointsso it is
.main-content p {
font-weight: bold
}
Richard Srery
640 Pointsi meant
.main-content p {
font-weight: bold;
}
Greg Kaleka
39,021 PointsRichard - you can edit your comments/answers after the fact by clicking on the rectangle with three dots that's after every post of yours. Helps keep forum threads clean - this one is a mess haha.
Viraj Kokane
17,531 PointsViraj Kokane
17,531 PointsHi Greg how do you post your code in the black box in forum ?
CSSThanks Greg for your help.
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsHi Viraj,
When you're commenting, you'll see a link below the text area that says Markdown Cheatsheet. It has some tips for how to style your posts. You can also watch the Tips for asking questions video in the right sidebar ->.
To make a code block like the one above, you just do this:
```CSS
[your code here]
```
Note those are backtics ` and not apostrophes '. You'll find them in the top left of your keyboard, under the ~.
You can replace the "CSS" with whatever language you're using - html, javascript, python, etc.
Richard Srery
640 PointsRichard Srery
640 Pointsi can't do a question on a quiz "We define the universal selector with a(n) ______."
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsHi Richard,
I would take another look at the video, or do a quick google search for something like "CSS universal selector" - it's good to get in the habit of finding answers to questions like these :). If you're stuck, post another question in the forum, but I'm confident you'll find your answer in about 10 seconds :)
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsViraj Kokane, you have to put the ``` on it's own line, and the code has to start on a new line as well.