The <picture> element contains zero or more <source> elements and one required <img>. The browser picks the best matching source; otherwise it uses the <img>src.
Common jobs: art direction (different crops per viewport), format fallback (AVIF/WebP then JPEG), and saving bandwidth. For the same image at 1x/2x densities, prefer srcset on <img> alone.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about March 2016.
img still displays.
The selected URL is shown in the space of the <img>. Put alt, width/height, and CSS like object-fit on that <img>.
Syntax
HTML Syntax
syntax.html
<picture><source>… <img></picture>
Both start and end tags are required. Order: any number of <source>, then exactly one <img>.
Reference
Attributes
<picture> has no element-specific attributes. Selection uses nested <source> (and the required <img>):
Skip <picture> when you only need resolution switching.
List candidates in srcset with 1x / 2x (or width w + sizes).
Keep src as a reliable fallback URL.
Use <picture> only when crops or formats must differ.
Edge Cases & Pitfalls
Most picture mistakes are missing img, wrong alt placement, or overusing the wrapper.
required
Always include img
<picture> without a trailing <img> is incomplete. The image that paints is that <img>.
a11y
alt on img only
Do not put alt on <picture> or <source>. Screen readers use the nested image.
css
Style the img
Use object-fit and object-position on the child <img>, not on <picture>.
srcset
Do not mix w and x
In one srcset, use either width descriptors or density descriptors — not both. Duplicate descriptors are invalid.
choice
Not always needed
Same crop, different DPI? Prefer <img srcset>. Reserve <picture> for art direction or format lists.
Compatibility
Browser Support
The <picture> element is core HTML in every modern browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<picture>
Widely available since about March 2016. Chrome, Firefox, Safari, Edge, and Opera all support picture with source and img.
96%Global support (approx.)
Google Chrome38+
Full support
Mozilla Firefox38+
Full support
Apple Safari9.1+
Full support
Microsoft Edge13+
Full support
Opera25+
Full support
Samsung InternetAll
Full support
Internet Explorer—
Not supported
<picture>Widely supported
Bottom line: Safe for modern sites. Always keep a working img fallback for older clients.
Remember
Key Takeaways
Structure: zero or more <source>, then one <img>.
Jobs: art direction (media) and format lists (type).
Display: the nested <img> shows the chosen URL and holds alt.
Simpler case: density-only needs → <img srcset> without picture.
One line: use <picture> when sources must differ by layout or format; always end with an <img>.
UA style
Default CSS Settings
<picture> itself has no special chrome. The visible box is the nested image:
default.css
picture {
display: inline;
}
/* Style the img that actually paints */
picture > img {
/* object-fit / object-position go here */
}
Exact UA values can vary; treat the <img> as the styling target.
Frequently Asked Questions
The picture element offers alternative images for different layouts or formats. Zero or more source elements come first; one img is required as the fallback and the element that actually displays.
No. It only supports global attributes. Selection is controlled by attributes on nested source elements (and the required img).
Use picture for art direction (different crops or assets per media) or format negotiation (AVIF/WebP then JPEG). For the same image at different densities, img srcset is often enough.
Always on the img inside picture. The picture and source elements do not take alt.
The browser uses the img element’s src (and any srcset/sizes on that img).
Apply object-fit and object-position on the child img, not on picture.