Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML Element

HTML Element

Example

Displaying different images for different screen sizes; if there is no match or the browser does not support the picture element, the img element is used:

<

picture

<

source

media

=

"

(min-width: 650px)

"

srcset

=

"

demo1.jpg

"

<

source

media

=

"

(min-width: 465px)

"

srcset

=

"

demo2.jpg

"

<img src="img_girl.jpg" picture>

Try it »


define

The picture element lets us display different images on different devices, typically for responsive design.

HTML5 introduced the element, which makes adjusting image resources more flexible.

The element has zero or more elements and one elements, each element to match different devices and reference different image sources; if there is no match, the element's src attribute URL is used.

Note: The element is placed after the last element; if the browser does not support it, the element's image is displayed.


Browser support

The numbers in the table indicate the first browser version number that supports the element.

Element
38.0 13.0 38.0 9.1 25.0

Differences between HTML 4.01 and HTML5

The attribute is newly defined in HTML5.


Global Attributes

The tag supports HTML Global Attributes.


Event attribute

The tag supports HTML Event Attributes.