HTML <img> sizes Attribute
Example
<img srcset="book.png 320w, cup.png 640w, desk.jpg 1200w" sizes="100vw" src="img-boy.jpg" alt="Boy" width="300" height="200">
Meaning
The sizes attribute specifies One or more strings separated by commas, specifies a set of source sizes.
Each source size consists of:
- A media condition. (This must be omitted for the last item in the list.)
- A source size value. (The selected source size affects the intrinsic size of the image display size if no CSS styling is applied. If the srcset attribute is absent, or contains no values with a width descriptor, then the sizes attribute has no effect.)
Standard Syntax
HTML: <img src="URL" alt="text" sizes="sizes" >,
XHTML: <img src="URL" alt="text" sizes="sizes" />
Advertisement
Attribute Values
| Value | Description |
|---|---|
| Media Conditions | This describe properties of the viewport, not of the image. For example (max-height: 500px) |
| Source size | Specifies the intended display size of the image. User agents use the current source size to select one of the sources supplied by the srcset attribute, when those sources are described using width (w) descriptors. |