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

attribute selector giving error

a[class="check"] { color:darkred; }

input[class="text"] { background-color:lightyellow; } ----------------------------------------------------this is giving error though it looks ok to me

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="#" class="check" title="More!">Duis ut velit faucibus</a>
    <p>
        Proin orci arcu, dapibus vel faucibus in, commodo in nunc. <a href="#" class="check">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[class="check"]
{
  color:darkred;
}

input[class="text"]
{
  background-color:lightyellow; 
}

4 Answers

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey Chetan,

just to make sure: Are you talking about the first task? If so, you have to select all anchor elements that have a title attribute which you do like so:

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

second one for text is not correct as per question and answer though it looks ok to me

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey again Chetan,

for the second one you have to select all inputs with a type attribute set to text. You're however selecting inputs with the class of text.

That should work:

input[type="text"] {
  background-color: lightyellow;
}

oops i got it , thanks for the reply