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

Question on Part 3 of the Attribute Selector Code Challenge

I'm stuck on Part 3 of this code challenge.

Instructions for Part 3:

Use an Attribute Selector to select the <a> element with the 'title' attribute. Give it a color property with a value of red.

My Code so far:

   div > a {
      color: green;
      font-weight: bold;
    }

    h2 + p {
      background-color: lightblue;
    }

    title + a {
      color: red;
    }

The link to the challenge: http://teamtreehouse.com/library/websites/css-foundations-second-edition/selectors/more-selectors-2

The video before the challenge: http://teamtreehouse.com/library/websites/css-foundations-second-edition/selectors/more-selectors

9 Answers

title { color: red; }

I guess that is all it wants? No need to call the anchor as it only asks for the Title attribute

In plain English title + a means ...

select any <title> elements that directly precede an <a> element

However there's no <title> element in the markup of this code challenge.

So instead what you want to do is use an attribute selector, and select any element with a title attribute

If you are still fuzzy about how to do this check out this tutorial on attribute selectors

Okay so I'm still struggling on this task.... James Barnett I just want to say that I like your approach to answering these forum posts. Like you said you make us work for the answer and just give us a hint, compared to just telling us which helps us to learn.

Iv spent quite a bit of time now trying to wrap my brain around this but I just can't seem to understand I'v read your link which helped me to learn more about this and I kind of get what you are saying when you say 'So instead what you want to do is use an attribute selector, and select any element with a title attribute' But I still don't completely understand it.

So the question reads 'Use an Attribute Selector to select the element......' does this mean use '+' or does it mean the title attribute inside of the p element

also I now know that there's no title element following a anchor element. But there is a title attribute following a anchor attribute which is nested (it is nested right??) inside of a paragraph element.

Can you help me some more. As you can tell I'm completely confused :s

OK I have the correct answer it is

[title] { color: red; }

You must scroll along to see the first paragraphs code.

<a href="#" title="foo">lorem iaculis ullamcorper</a>"

title="foo"

That is the only element with the title attribute in the markup. So it targets the title.

I hope this explains it and you understand it now and it clicks into place.

Sorry if I did not explain it well, maybe James can help with that

Hey jack thanks for the answer but I still don't understand it could I speak with you on skype? Skype: yacobm8

I got it, foo + a I just can't get the idea of combin to get answer or which way,

I was stuck on this too, then I realized I got confused with attribute and attribute value. Here is the logic I went through:

In the lesson the example is with the attribute named class.
[class]="foo"`

When the question is applied what does the code look like for an attribute selector?

To the Quiz! > Basically its asking to select any link <a> with the certain attribute name. 'title' attribute = they are saying there is an attribute named title within the quiz so that it looks like: < a href="#" title="foo">

Therefore the answer would look like: ^^^^^

Happy Coding!

I, too, had big problems with this because of the possible ambiguity in the question for someone new to the syntax and vocab. There might have been a less ambiguous example for this I would venture. Also having to jump between the vid and the questions each time was a little tiresome when this becomes the case. Following through the logic does get you there in the end and proves the point about specificity but it is frustrating.