HTML & CSS
/Beginner
Responsive Images
Definition
Images that scale nicely to fit any browser size. In modern web development, an image should never overflow its container or stretch out of proportion.
Explain Like I'm New
If you put a 2000px wide 4K image on a 400px wide iPhone, the image will physically stick out of the phone's screen and cause a horizontal scrollbar. You fix this by telling the image: 'Never be wider than your parent container'.
Real World Example
The holy grail rule of responsive images: `img { max-width: 100%; height: auto; }`.
Common Use Cases
- •Mobile friendly design
- •Preventing layout breakage
Interactive Example
Interview Questions
basic
- What CSS property prevents an image from overflowing its container?
intermediate
- Why use `max-width: 100%` instead of `width: 100%`?