HTML <소스> srcset 속성

❮ HTML <소스> 태그

예시

두 개의 소스 파일과 대체 이미지가 있는 <picture> 요소:

<picture>
  <source media="(min-width:650px)" srcset="img_pink_flowers.jpg">
  <source media="(min-width:465px)" srcset="img_white_flower.jpg">
  <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
</picture>

정의 및 사용

srcset속성은 다양한 상황에서 사용할 이미지의 URL을 지정합니다 .

이 속성은 <source>에서 사용될 때 필요합니다 <picture>.


브라우저 지원

표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.

Attribute
srcset 38.0 13.0  38.0 9.1 25.0

통사론

<source srcset="URL">

속성 값

Value Description
URL Specifies the URL of the image.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/flower.jpg")
  • A relative URL - points to a file within a web site (like href="flower.jpg")

❮ HTML <소스> 태그