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 trialSteve Leichman
7,008 PointsAmpersand Post-Selector - Help Please
I've been working on this and I can't figure out what's wrong. The direction is to add an exception for <a> tags that are are in the <div> with a class of .footer: those links should be purple. Use the post-selector ampersand to achieve this.
Here's what I have:
p{
a{
color:red;
.footer &{
color: purple;
}
}
>a{
color:blue;
&:hover{
opacity:0.5;
}
}
}
Can someone please tell me what I'm doing wrong? I'm sure it's something small and stupid.
Thank you.
6 Answers
Branko Veljkovic
6,684 Pointshere it is: p { a {color:red;}
a {color:blue; &:hover{opacity:0.5;} div.footer & {color:purple;} } }
That worked for me
erick Hernandez
7,060 Pointsi realize this post is old but just thought id put this here just in case someone stumbles upon for help. Just have to write this outside your previous 'P' tag nested code.
p {
a {
color:red;
}
>a {
color:blue;
&:hover{
opacity:0.5;
}
}
}
// add outside of previous code
a{
div.footer &{
color: purple;
}
}
Steve Leichman
7,008 PointsThanks, Branko. I tried your suggestion but unfortunately it didn't work. I feel like I've tried all variations of '''.footer &''' and '''&.footer''' in more or less every spot, but with no success. This is making me nuts.
Steve Leichman
7,008 PointsYes! Thank you!
Gerardo Mier y Teran
Courses Plus Student 3,936 PointsOut side the tag p a { div.footer & { color:purple; } }
Branko Veljkovic
6,684 Pointstry putting ampersand (&) character before class, like: ''' p{ a{ color:red; &.footer{ color: purple; } } >a{ color:blue; &:hover{ opacity:0.5; } } } '''
Guy Noda-Bailey
18,837 PointsGuy Noda-Bailey
18,837 PointsThanks Branko,
I just wanted to reformat your answer so that it would be a bit easier to figure out why it works. ;)
aaaah!