Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Foundations Selectors Basic Attribute Selectors

Jason Mc Dermott
Jason Mc Dermott
11,496 Points

Attribute selector question

the full title of this challenge is 'Create an attribute selector that will target <a> elements with a title attribute and color property with the value darkred' This looks straight forward enough and the video was quite clear, but its the last bit about the color property that threw me off. Any input would be much appreciated, thanks.

4 Answers

John Wheal
John Wheal
27,969 Points
[title]{
  color: darkred;
}

Darkred is just a color.

Was that the answer? This looks wrong to me. John is targeting all elements with a title attribute and giving them 'color:darkred;'. But that isn't what the question says?

Jason Mc Dermott
Jason Mc Dermott
11,496 Points

it worked in the end, I did try it as a[title] {color:darkred;} and it wasn't accepting.

Again the question was 'Create an attribute selector that will target <a>elements with a title attribute and color property with the value darkred' .

Another sample I picked up from w3schools.com on CSS [Attribute] Selectors

'The [attribute] selector is used to select elements with the specified attribute. The following example selects all <a> elements with a target attribute:

Example

a[target] { background-color: yellow;}

So really target is only being swapped out for title..?

Yeah, that doesn't make sense.

Plus, the question (as I interpret it) is asking you to SELECT all elements with a title attribute and HAVE a darkred color property. That is different to: "target all elements with a title attribute and GIVE them a darkred color property", which is what the 'correct' answer seems to be doing to me.