Art Direction and Varying Aspect Ratios
What you'll learn: How to serve images with different aspect ratios to mobile versus desktop using the <picture> element for purposeful art direction.
Why Different Aspect Ratios Matter
Sometimes the same aspect ratio doesn't work well across all screen sizes. A wide landscape photo might look stunning on desktop but become tiny and unreadable on mobile. Art direction lets you serve a square crop for mobile and a wide crop for desktop — different compositions of the same image, each optimized for its context.
The Picture Element Strategy
You've learned to use <picture> with <source> elements and media attributes. Now combine that with different aspect ratio images:
<picture>
<!-- Mobile: square crop (1:1) -->
<source media="(max-width: 768px)"
srcset="hero-square-500.jpg">
<!-- Desktop: wide crop (16:9) -->
<source media="(min-width: 769px)"
srcset="hero-wide-1200.jpg">
<img src="hero-wide-1200.jpg"
alt="Mountain landscape at sunset"
width="1200"
height="675">
</picture>
The mobile version (square) might show a close-up of a person's face, while the desktop version (wide) shows them in the full landscape context. Different compositions, different stories, same subject.
Preventing Layout Shift
Always set width and height on the fallback <img> to prevent layout shift. Use aspect-ratio CSS or the padding-bottom technique on the container to reserve space for different aspect ratios on different breakpoints.
Key Takeaway: The <picture> element enables art direction by serving images with different aspect ratios and crops to different screen sizes, ensuring optimal composition and readability at every viewport width.