Skip to content
Performance·Intermediate·Conceptual·1 min read

Why does an image need explicit width and height even with responsive CSS?

Short interview answer

So the browser can compute the aspect ratio and reserve the correct layout box before the file downloads, preventing the content jump measured as Cumulative Layout Shift. The attributes set the ratio; CSS still controls the final rendered size.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Image and asset optimization

Related questions