media

<img>

Embeds a raster or vector image into the document. Use it for content images; use CSS background-image for purely decorative visuals.

<img src="cat.jpg" alt="Sleeping cat" width="640" height="360">

Common attributes

Attribute Purpose
src Image URL (required)
alt Text alternative for AT and broken images
width Intrinsic width in pixels
height Intrinsic height in pixels
loading eager | lazy — defer offscreen images
decoding sync | async | auto
srcset Responsive candidate sources
sizes Layout hint for srcset selection

Examples

<img src="/logo.svg" alt="Utilko" width="120" height="32">

Logo with explicit dimensions to prevent CLS

<img src="hero.jpg" alt="" loading="lazy" decoding="async">

Decorative image, lazy-loaded

<img srcset="s.jpg 480w, m.jpg 800w, l.jpg 1600w" sizes="(max-width:600px) 100vw, 800px" src="m.jpg" alt="Landscape">

Responsive image with srcset/sizes

Gotcha

The alt attribute is required — use alt="" for purely decorative images so screen readers skip them. Always set width and height (or aspect-ratio in CSS) to reserve space and avoid Cumulative Layout Shift.

Related tags

← All HTML tags · CSS selectors · HTML entities