Module lessons (1/4)
Responsive <picture>, srcset, sizes & Art Direction
Switch cropped hero assets across breakpoints via <picture> media rules alongside aspect-ratio and object-fit without layout shift.
What you'll learn in this lesson
- Distinguish resolution/DPI switching (
srcset+sizes) from breakpoint crop Art Direction (<picture>+<source media>). - Prevent Cumulative Layout Shift (CLS) on responsive media using
width/heighthints,aspect-ratio, andobject-fit: cover. - Keep every responsive
<picture>and<figure>clean at narrow375pxmobile widths without horizontal overflow.
Overview
Most responsive images only need the same subject at different pixel widths—where browser resolution selection via <img srcset="..." sizes="..."> shines. Switch to <picture> whenever the crop, orientation, or file format itself changes by viewport width (for example, serving a tight vertical 4:5 portrait on mobile and a wide 16:9…
Sections covered in this lesson
- 1When
srcsetIs Enough vs<picture>Art Direction
Unlock "Responsive <picture>, srcset, sizes & Art Direction" and the full Modern HTML & CSS curriculum
Switch cropped hero assets across breakpoints via <picture> media rules alongside aspect-ratio and object-fit without layout shift.
Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.