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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Frederik Delfosse](https://secure.gravatar.com/avatar/76576f706f58e422e446da3c5509f170?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Frederik Delfosse
1,874 PointsCreate a new rule using the selector that targets an element only if its ID matches the hash in a URL.
How do you do this? I am doing something wrong but do not know what...
:target([id="#"]) { background-color: tomato; }
4 Answers
![Frantisek Musil](https://secure.gravatar.com/avatar/1448c2f4dc5e6e14a1515f72ef2ee7dc?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Frantisek Musil
5,403 PointsHmmm, I am wondering why would you ever use hash tag as ID of element. This is used just for testing purposes but not in real life projects.
However, if you want to target all the elements, that contain # + some other characters (id="#example" or id="example#" or id="exa#ple" or just id="#") you should use following selector
*[id^="#"] {
background-color: tomato; /* or any different styles you want to apply */
}
Let me know if it has helped you.
Frank
![Frederik Delfosse](https://secure.gravatar.com/avatar/76576f706f58e422e446da3c5509f170?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Frederik Delfosse
1,874 PointsI am really sorry but that did not work.
This is the Question: 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.
![Frederik Delfosse](https://secure.gravatar.com/avatar/76576f706f58e422e446da3c5509f170?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Frederik Delfosse
1,874 PointsApparaently this was the correct answer
:target { background-color: #EA2E49; }
![Łukasz Czuliński](https://uploads.teamtreehouse.com/production/profile-photos/835352/micro_96da200bd1cba0bf7dc61d7781d00774.jpg)
Łukasz Czuliński
8,646 PointsI had to Google this to find out the answer. I don't understand why your first one (and mine) didn't work. Can someone enlighten us?