HTML Tags

HTML <picture> Tag

The <picture> tag in HTML is used to provide multiple image sources for responsive designs.
It allows the browser to choose the most suitable image based on screen size, resolution, or format support.
It’s commonly used with <source> and <img> tags inside it.

Syntax

<picture>
  <source srcset="image-small.jpg" media="(max-width: 600px)">
  <source srcset="image-large.jpg" media="(min-width: 601px)">
  <img src="image-default.jpg" alt="Description">
</picture>

Attributes

AttributeDescription
srcsetSpecifies the image URL(s) to use for a particular media query or resolution.
mediaDefines a media condition (like in CSS @media) to choose the appropriate image.
typeSpecifies the MIME type of the image (e.g., image/webp).
altProvides alternative text for the <img> tag (required for accessibility).

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Picture Tag Example</title>
</head>
<body>

  <h2>Responsive Images with &lt;picture&gt;</h2>
  <picture>
    <source srcset="https://picsum.photos/id/237/300/300.webp" media="(max-width: 600px)">
    <source srcset="https://picsum.photos/id/237/600/300.webp" media="(min-width: 601px)">
    <img src="https://picsum.photos/id/237/200/200.webp" alt="Sample Responsive Image" width="600">
  </picture>

</body>
</html>

Output

Browser Output

Displays a responsive image that changes automatically based on the screen width.
Use our Try It Editor to resize the browser window and see the image switch between image-small and image-large.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes❌No

<picture> is not supported in Internet Explorer 9.
The <img> element inside <picture> acts as a fallback for unsupported browsers.
Ideal for responsive images and modern formats like WebP.

Notes

  • The <picture> element itself does not display anything — the <img> inside it is what’s visible.
  • You can include multiple <source> tags with different media queries or file formats.
  • Use <picture> for art direction (different images for different devices) rather than simple scaling.
  • Always include alt text in <img> for accessibility.

Conclusion

The <picture> tag provides a powerful method for delivering responsive and adaptive images.
It improves performance and user experience by letting browsers choose the most appropriate image based on screen size or format support.

Sign In Form

User your email and password to singn in

Provide your email and we will send you a password reset link.

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend