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

I think my code is correct, but it says to set it to darkred. My code: a [title="text"] { color: darkred; }

The challenge says to:

"Create an attribute selector that will target <a> elements with a title attribute. Add a color property with the value darkred."

But after my code it tells me: "Bummer! Please check your attribute selector, make sure the color is set to 'darkred'."

Thoughts?

index.html
<!DOCTYPE html>
<html>
<head>
    <title>Attribute Selectors</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sed egestas tortor, vel tincidunt dolor.
    </p>
    <a href="#" title="More!">Duis ut velit faucibus</a>
    <p>
        Proin orci arcu, dapibus vel faucibus in, commodo in nunc. <a href="#">Vestibulum erat dolor laoreet</a> nec cursus non, luctus ut elit. In sed congue lectus, id ullamcorper massa. <a href="#" title="More!">View more &raquo;</a>
    </p>
    <form>
        <input type="text" name="email">
        <input type="submit" name="submit">
    </form>
</body>
</html>
style.css
/* Complete the challenge by writing CSS below */

 a [title="text"] {
    color: darkred;
 }

2 Answers

You are close.

However, your code would only target children of 'a' elements with a title named "text".

This is the solution, which would target only 'a' elements that contain any title

a[title] {
 color: darkred; 
}

Notice there is no space in a[title] because we want to target anchor elements with a title. The space would cause it to target children of the anchor element.

Here is a codepen that demonstrates this. http://codepen.io/jessecfisher/pen/VYaypj

Thank you Jesse, that fixed it and I also appreciate the reference link to Codepen.

Hi Michael,

Your code is just barely off; need to remove the space between 'a' and '[title="text"]'.

a[title="text"] {
    color: darkred;
 }

Thank you for responding Robert. I have updated the code and it works.