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

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.