The HTML decoding attribute
Quick answer
The HTML decoding attribute hints how the browser should decode the image relative to rendering the rest of the page. It is used on the <img> element.
Overview
The decoding attribute hints the image decoding strategy. It is used on the <img> element.
It relates to images: their source and responsive variants, dimensions, and loading and decoding behavior. Setting the right attributes keeps images sharp, fast and accessible.
Syntax
<img src="p.jpg" decoding="async" alt="">
Values
| Value |
|---|
| auto (default) | sync | async |
Best practices
Frequently asked questions
What does the decoding attribute do?
Hints the image decoding strategy.
How do I make images responsive?
How do I stop images causing layout shift?
Which elements use the decoding attribute?
It is an element-specific attribute, used on the
<img> element.