👀 Live Preview
Resize the window to see the image change at breakpoints:
Green at 1200px+, orange at 768px+, red below that.

The <picture> tag delivers responsive, device-aware images. This guide covers syntax, source attributes, art direction, accessibility, and browser support for beginners.
Adapt to screen size.
Nested structure.
Image URL lists.
Breakpoint rules.
Different crops.
Always include alt.
<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.
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.
The <picture> tag employs a nested structure with one or more <source> elements and an <img> fallback:
<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>img with src and descriptive alt text.source elements from most specific to most general.srcset and media on source, not on picture.type on source to offer WebP/AVIF with JPEG fallback.| Topic | Code Snippet | Notes |
|---|---|---|
| Container | <picture>...</picture> | Wraps sources + img |
| Breakpoint | media="(min-width: 768px)" | On source element |
| Image URLs | srcset="photo.jpg" | On source element |
| Format hint | type="image/webp" | Modern format first |
| Fallback | <img src alt> | Required inside picture |
| Browser support | Modern 100% | IE: img fallback |
<picture> vs <img>| Approach | Best for | Example |
|---|---|---|
<img srcset> | Same image, different resolutions | Retina / responsive sizing |
<picture> | Different crops or formats | Art direction, WebP fallback |
<source> | Candidate inside picture | media + srcset rules |
The <picture> element has no tag-specific attributes. Responsive behavior comes from child <source> and <img> elements:
<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 sourceComma-separated image URLs and width or density descriptors.
srcset="photo.jpg"media sourceMedia query that must match for this source to be used.
media="(min-width: 768px)"type sourceMIME type so browsers skip unsupported formats.
type="image/webp"alt imgRequired accessible description on the fallback img.
alt="Team photo"Deliver breakpoint-based images and art-directed crops with source and img.
Resize the window to see the image change at breakpoints:
Green at 1200px+, orange at 768px+, red below that.
The <picture> tag adapts images to screen size, resolution, and layout needs through multiple source candidates.
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.
<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>The picture tag allows for art-directed images, where different images are served based on the layout or design requirements of the webpage.
<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>alt text on the fallback img; it represents the entire picture for assistive technology.alt="" only when the image is purely decorative.Add source elements with media and srcset, then an img fallback.
Each source is checked top to bottom until one matches.
The chosen URL renders through the nested img element.
Users get the right image for their device without loading every variant.
The <picture> element has full support in all modern browsers. Legacy Internet Explorer ignores the wrapper but still shows the nested img fallback.
Chrome, Firefox, Safari, Edge, and Opera all evaluate source rules natively.
Bottom line: Always include a fallback img so older browsers still show an image.
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.
img with alt textsource elements from specific to generalsrcset on picture instead of sourcealt on the fallback imgpicture when plain img srcset is enough<picture>Bookmark these before you ship responsive images.
Wraps sources + img.
Structuremedia + srcset rules.
CandidatesRequired with alt.
SafetyBreakpoint images.
LayoutDifferent crops.
DesignIE: img only.
Compatibilitysource for the user’s device.source elements inside picture, not on picture itself.img is the fallback and carries the alt text.source rules but still renders the nested img.Practice <picture> with breakpoint sources and art direction in the Try It editor.
6 people found this page helpful