Skip to the page
html reference · links & media

HTML <picture> / <source> tags

closing tag
<picture> required; <source> is void
void element
<source> only
lives inside
anywhere in <body>
typically holds
one or more <source> tags, then one fallback <img>

Where it goes

Around an <img>. The <source> tags come first, best option first. The browser takes the first one it can use. The <img> comes last.

Example

<picture>
  <source srcset="photo-small.jpg" media="(max-width: 600px)">
  <img src="photo-large.jpg" alt="A mountain view">
</picture>

Open this example in the editor →

Common mistakes

  • Leaving out the <img>. <picture> shows nothing on its own. The <img> is what displays. <source> only says which file to use.
  • Putting the <img> before the <source> tags. The browser stops looking when it reaches the <img>, so anything after it is ignored.
  • Putting alt on <picture> or <source>. It belongs on the <img>, the image that actually shows.

Related

Updated 24 October 2026. Practice it in the html route, or read more on MDN.