Module img

Module img 

Source
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 shift
  • loading: Lazy loading behavior (eager/lazy)
  • srcset: Responsive image sources
  • sizes: 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 alt attribute.
CROSSORIGIN
The crossorigin attribute.
DECODING
The decoding attribute.
HEIGHT
The height attribute.
ISMAP
The ismap attribute.
LOADING
The loading attribute.
REFERRERPOLICY
The referrerpolicy attribute.
SIZES
The sizes attribute.
SRC
The src attribute.
SRCSET
The srcset attribute.
USEMAP
The usemap attribute.
WIDTH
The width attribute.