Description

The HTML <img> element embeds an image into the document. It is a void element (self-closing), meaning it has no closing tag.

Images are essential for web content. Always provide descriptive alt text for accessibility — screen readers use the alt attribute to describe images to visually impaired users, and it also displays when the image fails to load.

CSS Display:inline-block

Syntax

<img src="image.jpg" alt="Description of image">

Examples

Basic Image
<img src="https://htmlsave.com/favicon-96x96.png" alt="HTML Save Logo">
Displays an image with alt text for accessibility.
Image with Dimensions
<img src="https://htmlsave.com/favicon-96x96.png" alt="HTML Save Logo" width="48" height="48">
Setting width and height prevents layout shift as the image loads.
Lazy Loading
<img src="https://htmlsave.com/favicon-96x96.png" alt="HTML Save Logo" loading="lazy">
Lazy loading defers loading images that are below the fold, improving page performance.

Notes

Always include both width and height attributes to prevent Cumulative Layout Shift (CLS), which is a Core Web Vital metric that affects SEO.

Use loading="lazy" for images that are not immediately visible when the page loads to improve performance.