Expand description
Attribute names for image (<img>) elements.
§Purpose
The <img> element embeds images into documents. It supports responsive
images, lazy loading, and various performance optimization features.
§Common Attributes
src: Image source URL (required)alt: Alternative text for accessibility (required)width/height: Dimensions to prevent layout shiftloading: Lazy loading behavior (eager/lazy)srcset: Responsive image sourcessizes: Image sizes for different viewport widths
§Example
<img src="photo.jpg" alt="A beautiful sunset" width="800" height="600">
<img src="hero.jpg" alt="Hero" loading="eager">
<img src="gallery.jpg" alt="Gallery" loading="lazy"
srcset="small.jpg 480w, large.jpg 1024w" sizes="(max-width: 600px) 480px, 1024px">§WHATWG Specification
Constants§
- ALT
- The
altattribute. - CROSSORIGIN
- The
crossoriginattribute. - DECODING
- The
decodingattribute. - HEIGHT
- The
heightattribute. - ISMAP
- The
ismapattribute. - LOADING
- The
loadingattribute. - REFERRERPOLICY
- The
referrerpolicyattribute. - SIZES
- The
sizesattribute. - SRC
- The
srcattribute. - SRCSET
- The
srcsetattribute. - USEMAP
- The
usemapattribute. - WIDTH
- The
widthattribute.