HTML Attributes

HTML sizes attribute

On responsive images, describes the expected display slot width used with width-descriptor candidates. On icon links, describes icon dimensions. The grammars differ. Applicable elements include: <img>, <link>, <source>. Check each element’s value rules. Example uses illustrative URLs or local assets; provide the corresponding files or application endpoints when running it.

Formal Syntax & Structure

html syntaxhtml
sizes="(max-width: 600px) 100vw, 50vw"

Parameters & Attributes

NameTypeDescription
sizesresponsive source size list or icon sizesOn responsive images, describes the expected display slot width used with width-descriptor candidates. On icon links, describes icon dimensions. The grammars differ.

Working Example

Example Snippethtml
<img src="small.jpg" srcset="small.jpg 400w, large.jpg 800w" sizes="(max-width: 600px) 100vw, 50vw" alt="Landscape">

Browser Compatibility

Minimum supported versions across modern rendering engines

Blink (modern)
Chrome
38
Yes
EdgeHTML / Blink
Edge
12
Yes
Gecko
Firefox
38
Yes
WebKit
Safari
9.1
Yes
Basic responsive sizes on img; the newer auto value has separate support. This is retained historical source evidence, not a new browser test.
HTML Living Standard
HTML Reference