#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
4 min read
•Question 20 of 49medium

What is the Picture Element?

Responsive images with art direction.

What You'll Learn

  • Art direction for images
  • Format fallbacks
  • When to use picture vs srcset

What is Picture Element?

The <picture> element provides art direction for responsive images - showing different images (not just sizes) based on screen conditions.

Art Direction Example

index.htmlHTML
<picture>
  <source media="(min-width: 1200px)" srcset="hero-wide.jpg">
  <source media="(min-width: 768px)" srcset="hero-medium.jpg">
  <img src="hero-mobile.jpg" alt="Hero image">
</picture>

Format Fallback

Serve modern formats with fallback:

index.htmlHTML
<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Photo">
</picture>

Picture vs Srcset

  • <picture>: You control which image displays
  • srcset: Browser chooses best size