HTML Picture Tag Explained: Serve Different Images Based on Screen Size
The HTML <picture> tag allows developers to provide multiple versions of an image, letting the browser select the most suitable one based on the device's screen size. It works by pairing one or more <source> elements — each with media conditions like max-width or min-width — with a fallback <img> element. The browser evaluates the source conditions from top to bottom and displays the first matching image, or defaults to the <img> tag if none match. This approach improves responsiveness by serving smaller images to mobile users for faster load times and larger images to desktop users for better clarity. Overall, the <picture> tag gives developers greater control over image presentation across different devices.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in