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
Manjula Kashyap
2,694 PointsChanging 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
Wayne Priestley
19,579 PointsHi,
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.
Manjula Kashyap
2,694 PointsThanks Wayne,
But the link in this case is the image and its description. I still don't understand.
Wayne Priestley
19,579 PointsThis 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.
Manjula Kashyap
2,694 PointsThank you very much Wayne! I think I understand now.