
Brian S. answered 06/12/25
Html and CSS for Websites
Hi there,
The standard way to scale down images in css is this:
img {
max-width: 100%;
height: auto;
}
This is mobile friendly code.
Brian S. answered 06/12/25
Html and CSS for Websites
Hi there,
The standard way to scale down images in css is this:
img {
max-width: 100%;
height: auto;
}
This is mobile friendly code.
Anonymous A. answered 12/06/19
HTML Expert with 10+ years of experience
Hello,
Resizing with CSS is always done proportionally unless you declare it otherwise.
For example, if you have an image whose size is 100x100, if you resize it with CSS like this:
...then that image will 'automatically' be 200px tall as well, even if the height wasn't declared.
However, if you declare the height to a value different than 200px (for this example of course), then the image will be rather than 'scaled' it will be simply resized to the dimensions you declared.
Taking the same 100x100 image, if you declare the height:
...then the image will lose its proportion/ratio and will appear vertically squished.
Hope this helps.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.