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 Selectors Basic Attribute Selectors

Matthew Clark
Matthew Clark
7,255 Points

What is the issue with my code here?

/* Complete the challenge by writing CSS below */ a title [class] { color: darkred; }

1 Answer

Ethan Lowry
PLUS
Ethan Lowry
Courses Plus Student 7,323 Points

What are you trying to achieve exactly? Normally when using attribute selectors you need to apply both the attribute name and the value for that attribute that you want your selector to select. Or if you just want to check if the element has the attribute at all, and don't care about its value, you would just supply the attribute name, sort of like you have done there.

For example, the following would select input elements with a "type" attribute of "text":

input[type="text"] { padding: 3px; }

And this would just select all image elements with an 'alt' attribute:

img[alt] { border: 1px solid black; }

But your example is a little strange - you seem to be trying to select the "class" attribute - but selecting by class is such a standard and command action in CSS that there is no need for complex attribute selectors, instead you would just use:

a.class_name { color: red; }

Perhaps that was just a bad example on your part, though.