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 How to Make a Website Styling Web Pages and Navigation Make a CSS Image Gallery

Juan Carlos Hernández
Juan Carlos Hernández
8,316 Points

I can't reach this code challenge

"Add CSS that will allow all images to fill their parent element."

I'm writing this : img{ width: 100%; }

Am I doing something wrong ?

3 Answers

Stone Preston
Stone Preston
42,016 Points

try using max-width instead of width

Rémi BRUGUIER
Rémi BRUGUIER
4,970 Points

you may want to try max-width instead of width ;)

Jimmy Hsu
Jimmy Hsu
6,511 Points

Logically that would make sense, but CSS will have none of that in this instance.

img {
  max-width: 100%;
}

It's max-width and not just width to have images fill their parent. Just a quirk of CSS you'll come to remember.

Stone Preston
Stone Preston
42,016 Points

width is a valid css property just fyi

Jimmy Hsu
Jimmy Hsu
6,511 Points

Yup, I meant for just this case. I'll modify my answer to be more specific.