HTML <picture> Tag

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 2 Examples
HTML5 Media

What You’ll Learn

The <picture> tag delivers responsive, device-aware images. This guide covers syntax, source attributes, art direction, accessibility, and browser support for beginners.

01

Responsive Images

Adapt to screen size.

02

source + img

Nested structure.

03

srcset

Image URL lists.

04

media Queries

Breakpoint rules.

05

Art Direction

Different crops.

06

img Fallback

Always include alt.

What Is the <picture> Tag?

The <picture> tag is a versatile HTML5 element designed to provide a flexible and responsive approach to displaying images on a webpage. It allows developers to include multiple sources for an image based on factors like screen size, display resolution, and other device characteristics.

Valid HTML5 — Responsive Image Container

The browser evaluates each <source> in order and displays the first match. The nested <img> is the required fallback.

Use picture when you need art direction (different crops per layout) or format switching (WebP with JPEG fallback). For simple resolution switching, img with srcset alone may be enough.

📝 Syntax

The <picture> tag employs a nested structure with one or more <source> elements and an <img> fallback:

syntax.html
<picture>
  <source srcset="image-large.jpg" media="(min-width: 1200px)">
  <source srcset="image-medium.jpg" media="(min-width: 768px)">
  <img src="image-small.jpg" alt="Description of the image">
</picture>

Syntax Rules

  • Always include a final img with src and descriptive alt text.
  • List source elements from most specific to most general.
  • Put srcset and media on source, not on picture.
  • Use type on source to offer WebP/AVIF with JPEG fallback.

⚡ Quick Reference

TopicCode SnippetNotes
Container<picture>...</picture>Wraps sources + img
Breakpointmedia="(min-width: 768px)"On source element
Image URLssrcset="photo.jpg"On source element
Format hinttype="image/webp"Modern format first
Fallback<img src alt>Required inside picture
Browser supportModern 100%IE: img fallback

⚖️ <picture> vs <img>

ApproachBest forExample
<img srcset>Same image, different resolutionsRetina / responsive sizing
<picture>Different crops or formatsArt direction, WebP fallback
<source>Candidate inside picturemedia + srcset rules

🧰 Attributes

The <picture> element has no tag-specific attributes. Responsive behavior comes from child <source> and <img> elements:

source-attributes.html
<picture>
  <source srcset="hero-wide.webp" type="image/webp" media="(min-width: 900px)">
  <img src="hero-mobile.jpg" alt="Product on a desk">
</picture>
srcset source

Comma-separated image URLs and width or density descriptors.

srcset="photo.jpg"
media source

Media query that must match for this source to be used.

media="(min-width: 768px)"
type source

MIME type so browsers skip unsupported formats.

type="image/webp"
alt img

Required accessible description on the fallback img.

alt="Team photo"

Examples Gallery

Deliver breakpoint-based images and art-directed crops with source and img.

👀 Live Preview

Resize the window to see the image change at breakpoints:

Responsive demo image that changes color by viewport width

Green at 1200px+, orange at 768px+, red below that.

📚 Common Use Cases

The <picture> tag adapts images to screen size, resolution, and layout needs through multiple source candidates.

Responsive Images

The primary use case for picture is to deliver images that adapt to various screen sizes and resolutions. By providing multiple sources, developers can ensure an optimal viewing experience across devices.

responsive-images.html
<picture>
  <source srcset="image-large.jpg" media="(min-width: 1200px)">
  <source srcset="image-medium.jpg" media="(min-width: 768px)">
  <img src="image-small.jpg" alt="Description of the image">
</picture>
Try It Yourself

Art Direction

The picture tag allows for art-directed images, where different images are served based on the layout or design requirements of the webpage.

art-direction.html
<picture>
  <source srcset="portrait.jpg" media="(orientation: portrait)">
  <source srcset="landscape.jpg" media="(orientation: landscape)">
  <img src="default.jpg" alt="Description of the image">
</picture>
Try It Yourself

♿ Accessibility

  • alt on img — Put descriptive alt text on the fallback img; it represents the entire picture for assistive technology.
  • Meaningful descriptions — Describe the image content, not just “photo” or the filename.
  • Decorative images — Use alt="" only when the image is purely decorative.
  • Same message across sources — All source variants should convey equivalent information.

🧠 How <picture> Works

1

Author lists sources

Add source elements with media and srcset, then an img fallback.

Markup
2

Browser evaluates rules

Each source is checked top to bottom until one matches.

Selection
3

Best image displays

The chosen URL renders through the nested img element.

Render
=

Optimized viewing experience

Users get the right image for their device without loading every variant.

Browser Support

The <picture> element has full support in all modern browsers. Legacy Internet Explorer ignores the wrapper but still shows the nested img fallback.

Baseline · HTML5

Responsive images everywhere

Chrome, Firefox, Safari, Edge, and Opera all evaluate source rules natively.

100% Modern support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer img fallback only
Partial
Opera Fully supported
Full support
<picture> tag 100% modern support

Bottom line: Always include a fallback img so older browsers still show an image.

Conclusion

Integrating the HTML <picture> tag into your web development toolkit empowers you to create visually stunning and responsive websites. By tailoring image sources to the characteristics of the user’s device, you can provide an enhanced and adaptable viewing experience.

💡 Best Practices

✅ Do

  • Include a default img with alt text
  • Test responsive images on phones and desktops
  • Order source elements from specific to general
  • Compress images for faster page loads

❌ Don’t

  • Put srcset on picture instead of source
  • Omit alt on the fallback img
  • Load huge images when small ones suffice
  • Use picture when plain img srcset is enough

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <picture>

Bookmark these before you ship responsive images.

6
Core concepts
📝 02

source

media + srcset rules.

Candidates
⚙️ 03

img Fallback

Required with alt.

Safety
📱 04

Responsive

Breakpoint images.

Layout
🎨 05

Art Direction

Different crops.

Design
🌐 06

Modern 100%

IE: img only.

Compatibility

❓ Frequently Asked Questions

It delivers responsive images by selecting the best source for the user’s device.
On source elements inside picture, not on picture itself.
Yes. The img is the fallback and carries the alt text.
Serving different image crops or compositions for different layouts or orientations.
IE ignores source rules but still renders the nested img.

Ship Responsive Images

Practice <picture> with breakpoint sources and art direction in the Try It editor.

Try responsive images →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful