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

HTML source srcset attribute

HTML The srcset attribute

HTML source Tag Reference HTML tag

Example

in is used in the tag to set images displayed on different screens:

<

picture

<

source

media

=

"

(min-width:650px)

"

srcset

=

"

https://static.jyshare.com/images/runoob-logo.png

"

<

source

media

=

"

(min-width:465px)

"

srcset

=

"

https://static.jyshare.com/images/code-icon-script.png

"

<

img

src

=

"

https://static.jyshare.com/images/mix/hjkg_icon.png

"

style

=

"

width:auto;

"

picture

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

property
srcset 38.0 13.0  38.0 9.1 25.0

Definition and Usage

The srcset attribute is used for image URLs displayed in different situations.

This attribute is needed when applied to the tag.

Differences between HTML 4.01 and HTML5

The tag is new in HTML5.

Syntax



Attribute values

Value Description
URL Specifies the URL of the media file.

Possible values:

  • Absolute URL - points to another website (such as href="https://www.runoob.com/horse.ogg")
  • Relative URL - points to a file within the website (such as href="horse.ogg")
  • |

    HTML source Tag Reference HTML tag