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!
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

James Pointer
5,257 PointsMore Selectors Challenge 3/4.
This has been asked a billion times, but I just cannot figure it out!
"Use an Attribute Selector to select the element with the 'title' attribute. Give it a color property with a value of red."
This is my code as it stands:
a[class~="foo"] {
color:red;
}
What is wrong with that? Thanks in advance.
9 Answers

Chase Lee
29,275 PointsLet me give you the answer. It's this:
a[title]{
color: red;
}

James Barnett
39,199 PointsOriginal instructions
Use an Attribute Selector to select the element with the 'title' attribute. Give it a color property with a value of red.
I think the confusion over trying to use a class to select a particular element come from phrase the element
instead of any element
.
The instructions could be better worded as
Use an Attribute Selector to select any element with a 'title' attribute. Give it a color property with a value of red.
I think that makes it much clearer you need something general
a[title]
In English that roughly translates to:
Selects any
a
element with atitle
attribute.
Instead of the very specific:
a[class~="foo"]
In English that roughly translates to:
Selects any
a
element with aclass
attribute that contains the wordfoo
.
Explainations from the SelectORacle

James Barnett
39,199 PointsGuil Hernandez - What are your thoughts on this?

Guil Hernandez
Treehouse TeacherJames Barnett – I see how the question is somewhat misleading. The good news is that I'm currently in the process of reshooting the first 3 stages of CSS Foundations. Part of this is rewriting some of the quizzes and code challenges. This will be one of them. :)
Thanks!

Elliott Frazier
Courses Plus Student 9,647 PointsGuil Hernandez - does the reshoot for the first three stages contain more information, or are your reshooting for other reasons?

Guil Hernandez
Treehouse TeacherThe same content will be covered, though much improved. I just felt like too much information was crammed into each video and the pace was too fast for beginners. So in the new videos, we slowed down the pace and broke the content up into more digestible bits of info. We're also adding awesome new graphics to help explain the content. :)

Elliott Frazier
Courses Plus Student 9,647 PointsGuil Hernandez - Yea I remembered having to re-watch some of the videos to grasp it all. Will I have to earn those badges again after you replace the old ones?

Guil Hernandez
Treehouse TeacherElliott Frazier – Nope, you shouldn't have to earn them again. But feel free to watch them :)

Elliott Frazier
Courses Plus Student 9,647 PointsGuil Hernandez - Awesome! Thanks for answering my questions.

Chase Lee
29,275 PointsTo select something with a class you would do this:
a.foo{
color: red;
}
Hope that helps.

James Pointer
5,257 PointsIt still doesn't work, it's supposed to be using the method in the Basic Selectors part 2 tutorial I think?

Chase Lee
29,275 PointsWhat attribute does it tell you to select? Put only that into the square brackets.

Elliott Frazier
Courses Plus Student 9,647 PointsI think you need to remove the quotation marks from around "foo".

James Pointer
5,257 PointsNope, neither work, getting rather annoying as I don't want to leave a section out and it really doesn't seem like I'm doing anything wrong, I'm doing it exactly as explained in the video as far as I can tell!..

Patrick Johnson
9,505 PointsAre you sure you're using the proper attribute selector? CSS-Tricks as a good little recap on what they all are. http://css-tricks.com/attribute-selectors/
Can you give more details to your issue? Without proper context it's tough to really help you out.

James Pointer
5,257 PointsI must not be although that is how it is taught in the video tutorial beforehand, or how I understand it at least. This is what the instructions say to do:
"Use an Attribute Selector to select the <a> element with the 'title' attribute. Give it a color property with a value of red."
And the title of the attribute that needs selecting is "foo". So I'm not sure what's wrong. Hope this helps a little more?
Thanks for that link also.

James Pointer
5,257 PointsWhat do you know, I just figured it out! Thanks for everyones answers :)

Garrett Whisenant
Courses Plus Student 3,337 PointsHey the first answer to this code challenge is
div > a{ color:green font-weight:bold }
right? i think my browser isn't working responding right or something please let me know if I am wrong

James Pointer
5,257 PointsI'm not sure if that's the right code or not, but one thing I noticed is that you're missing a couple of semi colons out. :)
James Barnett
39,199 PointsJames Barnett
39,199 PointsChase James -
I get that you were taking tidy on someone after going back and forth for a day.
However consider future forum searchers ...
Not really sure how this helps anyone learn anything. If I didn't already know how attribute selectors work I would be no wiser after seeing this answer.
I'm curious what others think about this.