Skip to content

A quick note on images

Most elements adapt and respond to the size of the viewport all on their own.

When working with background images, that means they may crop away some of the image.

However, with regular <img> elements, and a few others like <iframe>s, they don’t crop, or adjust in any way. They have a fixed size by default.

For images, that default size is their intrinsic size (whatever the actual size of the image is), and that can quickly lead to overflow issues.

There is a simple fix:

img {
display: block;
max-inline-size: 100%;
}

See the Pen images by Kevin (@kevinpowell) on CodePen.