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
Joan Marie Wilcox
513 PointsActive Deep Dives CSS Foundations - Selectors - Code Challenge More Selectors
The question states: use a child selector to select the anchor element that is a direct child of the div. Set its color to green and the font weight to bold.
I put div > a { color: green; font weight: bold; }
this is not working. What am I doing wrong?
18 Answers
James Barnett
39,199 Points@Joan - Those are some good notes and they are all correct
To recap the selectors mentioned in the video ...
-
>= direct child -
+= adjacent sibling -
~= general sibling
Joan Marie Wilcox
513 PointsI have watched the video several times and do not get this. My notes reads: -a child selector that selects an element that is a direct child of another element div >a { -an adjacent sibling selector that selects an element that is the next sibling in the document with the parent element h2 + p {
- general sibling selectors selects an element sibling but doesn't necessarily be a direct sibling ul~p {
- attribute selectors ie class [class] {
I just can't see this answer from the video discussion.
James Barnett
39,199 Points@Joan - It was just a typo, you forgot the dash.
It's font-weight not font weight.
James Barnett
39,199 Points@Christer - I think you got confused.
The > combinator is for the direct child. The space is the combinator for all children and is referred to as the descendant selector.
Colin Narver
1,365 PointsI like treehouse and have found these videos useful, but I have a serious issue with this deep dive.
I really wish the place holder text wasn't latin. Makes it very difficult to scan the text for elements. They all look the same and are hard to locate. Makes the lessons much more frustrating. \
I much prefer the way the "smells like bakin'" set of videos did this with simple, english text.
Brian Goldstein
19,419 PointsCan anyone tell me what it is I'm doing wrong here?
Use the Adjacent Sibling Combinator to select the <p> elements that immediately follow the h2. Set their background to lightblue.
h2 + p {
bg-color: light-blue;
}
the response: Bummer! The Adjacent Combinator is +, try double checking your css selectors.
James Barnett
39,199 PointsHint: bg-color is not a CSS property.
Brian Goldstein
19,419 Pointssorry - I tried both "background-color" and "bg-color" multiple times for that code challenge.
James Barnett
39,199 PointsBrian Goldstein - CSS color keywords don't have dashes or spaces in them.
Brian Goldstein
19,419 Pointsjust went back to it to try again. my entry:
h2 + p { background-color: light-blue; }
the response: Bummer! The Adjacent Combinator is +, try double checking your css selectors.
Seriously can't tell what the problem is here.
James Barnett
39,199 PointsTry reading the instructions closely:
Use the Adjacent Sibling Combinator to select the elements that immediately follow the h2. Set their background to lightblue.
Brian Goldstein
19,419 Pointsroger, wilco. thanks!
Brian Goldstein
19,419 Pointsand that worked!
jasonniebauer
28,801 PointsI'm stuck on the first question of this quiz too... I typed:
div > p { color: green; font-weight: bold; }
I get the response: Bummer! The child selector is >, try double checking your css selectors.
When I click refresh, I see that the code changes ALL the paragraphs in the div to green and bold instead of just the first paragraph. What am I missing?
jasonniebauer
28,801 PointsI just realized I should be using the anchor element and not the paragraph.
Tadeusz Krawczyk
2,088 Pointsand that worked! Thx
Lee Ann VanWinckel
1,480 PointsWhat's wrong here?
.div > a {
color: green;
font-weight: bold;
}
Christer Nordbø
2,133 PointsI believe the > selects ALL child elements. not just the direct child. so try changin your selector! Re-watch the video, they do emphasize it a little.