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 Selectors Going Further with Attribute Selectors and Pseudo-Classes Substring Matching Attribute Selectors Challenge

Kim Gee
Kim Gee
3,841 Points

Explain

This is a Code Challenge: Create a selector that targets an img element if its title value begins with "product-". Set the border color to lightblue. what do they mean by title????? I have this code that is wrong a[title^="product"] { border-color: lightblue; }

style.css
/* Complete the challenge by writing CSS below */
a[title^="product"] {
  border-color: lightblue; 
}

7 Answers

Kevin Korte
Kevin Korte
28,148 Points

Your selector is picking an anchor element but you mentioned in your text that the element it wants you to select is an image.

I think you are targeting the wrong element there it should be 'img' instead of 'a'. also want to make sure you get the string right. Hope this helps :]

/* Complete the challenge by writing CSS below */
img[title^="product-"] {
  border-color: lightblue; 
}
Kim Gee
Kim Gee
3,841 Points

Neither anchor or image is accepted as the correct answer.
img[title^="product"] { border-color: lightblue; }

Kevin Korte
Kevin Korte
28,148 Points

I went and looked at the question and noticed it asked to us the title attribute selector for an image that starts with product-, you are only using product and I bet that's why it won't pass.

Kim Gee
Kim Gee
3,841 Points

Does image have a title attribute? i don't see that it does. the ^ means for the browser to look at the image tag inside of a title attribute and the value of title should begin with product. But image does not have a title attribute? Is my thinking wrong?

Kevin Korte
Kevin Korte
28,148 Points

Images can have title attributes, yes. What it wants is a selector to for this HTML

<img src="path/to/img.jpg" title="product-101">
Kim Gee
Kim Gee
3,841 Points

so embarrass left out the "-" after product!

Kevin Korte
Kevin Korte
28,148 Points

You're welcome, and don't be embarrassed. Tiny oversights like this are super common even for most veteran of coders.