Loading lesson path
Concept visual
Start at both ends
<picture> element allows you to display different pictures for different devices or screen sizes.
Formula
The HTML < picture > Element<picture> element gives web developers more flexibility in specifying image resources.
<picture> element contains one or more <source> elements, each referring to different images through the srcset attribute. This way the browser can choose the image that best fits the current view and/or device.
<source> element has a media attribute that defines when the image is the most suitable.
Show different images for different screen sizes: <picture>
Formula
< source media ="(min - width: 650px)" srcset ="img_food.jpg">
< source media ="(min - width: 465px)" srcset ="img_car.jpg"><img src="img_girl.jpg"> </picture>
<img> element as the last child element of the <picture> element. The <img> element is used by browsers that do not support the <picture> element, or if none of the <source> tags match.
<picture> element:
The browser will use the first image format it recognizes: <picture> <source srcset="img_avatar.png"> <source srcset="img_girl.jpg"> <img src="img_beatles.gif"
alt="Beatles" style="width:auto;"></picture>
<source> element with matching attribute values, and ignore any following <source> elements.
<img>
<map>
<area> Defines a clickable area inside an image map <picture>
For a complete list of all available HTML tags, visit our HTML Tag Reference.