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

Changing image sizes css

I am doing the "How to make a website course". I am on "Styling Web Pages and Navigation" .

Here, for changing the image size on the sample page being created we use the following css:

img { max-width: 100%; }

why doesn't the following work instead?

gallery li a {

max-width: 100%; }

4 Answers

Hi,

The second example you gave is trying to give a link a max-width of 100% thats why it wouldn't work.
The first example gives the image a max-width of 100% of its parent.

Hope this helps.

Thanks Wayne,

But the link in this case is the image and its description. I still don't understand.

This is such a hard thing to put into words.

Its like link has no substance to the browser, its just a link tag. Wether it be text or an image, the link tag is just a path to that text or image.
But the image tag, the browser knows to expect content, so it can be instructed to give that content dimensions.

I'm not sure how well I've explained that, I know the answer in my head but getting it into text is difficult.

Anyway I hope this helped a little.

Thank you very much Wayne! I think I understand now.