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 Foundations Advanced Selectors Additional Pseudo-Classes

need help

I am not getting right answer to "Create a new rule using the selector that targets an element only if its ID matches the hash in a URL. Set the background color to tomato."

I tried with below, but both of them not work

a) *:[id="#"] { background-color:tomato }

// below i have used contains pseudoclass b) *:[id *="#"] { background-color:tomato }

Please let me know why is it not working.

4 Answers

:target { background-color: tomato;}

The question is worded kind of strange, keep in mind They want you to change the background color of the DIV the link selects, not the links background itself! ;)

Sorry for the crazy double post, the forums sometimes don't agree with what I am thinking... You should be able to delete an answer, or comment!!

Hi Timothy,

I guess I'm not really sure what "they" want. But I do know that while your code passes the code-challenge it turns nothing the color tomato. I even tried it in my own browser creating my own html and css files. Oh well.

Jeff

Hey Jeff, Use that code then click the internal link on the page. You should be able to see what it does. Tim

James Barnett
James Barnett
39,199 Points

Since this is a badge about pseudo-classes, try using the root & target pseudo-classes.

Hi Manjunath,

The following code works, but doesn't pass. Timothy's code passes but didn't work for me.

Jeff

Hey @Guil Hernandez

/* Write your CSS code below */
html
{
  background-color: lightblue;
}
a[href*="#"]
{
  background-color: tomato;
}

Keep in mind The question is worded kind of strange. They want you to change the background color of the DIV that the link selects, not the link 's background itself