Images in HTML
The <img> tag embeds images into a webpage. It is a self-closing tag — it has no content and no closing tag. Images are one of the most important elements for making pages visually engaging.
The img Tag and Its Attributes
<!-- Every img needs these 4 attributes --> <img src="ciweb-logo.png" alt="CIWeb Logo" width="200" height="80" loading="lazy" /> <!-- src can also be a full URL --> <img src="https://ciweb.in/images/hero.webp" alt="Students learning HTML at CIWeb" width="800" height="400" loading="lazy" />
The figure and figcaption Tags
<figure> <img src="shiva-teaching.jpg" alt="Shiva Saini teaching HTML" width="600" height="400" loading="lazy" /> <figcaption>Shiva Saini — Founder, Coding Infinite</figcaption> </figure>
Image Formats Guide
Google cannot see images. It reads the alt attribute to understand what the image shows. A good alt text like "Students learning HTML at CIWeb in 2026" tells Google your page is about HTML education. Bad alt text like "image1.jpg" tells Google nothing.
Without width and height attributes, the browser does not know the image size until it downloads. This causes the page to jump as images load — called Cumulative Layout Shift (CLS). Google penalizes pages with high CLS in search rankings.
By default, browsers download ALL images on a page even if they are far below the visible area. loading="lazy" tells the browser to only download an image when the user scrolls near it. This can cut initial page load time by 50% on image-heavy pages.