Account
Categories
Shobha
Shobha
The best way to predict the future is to invent it

How do you create a responsive image using CSS?

To ensure images resize appropriately within their container, the max-width property is used. By setting max-width: 100%, images will adjust their size to fit within the boundaries of their parent container, while maintaining their aspect ratio. This prevents the images from overflowing and ensures they remain responsive across different screen sizes. For example:

img {
max-width: 100%;
height: auto;
}