Advertisement
Home Open Editor ❯

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">

Try this code ❯

Meaning

The sizes attribute specifies One or more strings separated by commas, specifies a set of source sizes.

Each source size consists of:


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.
Home Open Editor ❯
Advertisement