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!

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

Finally, create a new selector that targets an img element if its src value contains the word "preview". Then, set its w

don't know that to do to the src

2 Answers

Hi Kameron,

Try the "contains" selector:

img[src*="preview"] { 
  width:100%; 
}
Lean Rasmussen
Lean Rasmussen
11,060 Points

I tied excatly that. even copied your code.. And I get an error that tells mer to set the width to 100%... I get an error on that piece of code.

Hi Lean,

I tried it again and the code works. Try having all 3 selectors in your code instead of replacing them. That might be the issue. At the end of the challenge it should look like this:

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

a[href$=".html"] {
  text-decoration: none;
}

img[src*="preview"] { 
  width:100%; 
}