Images
Charminar ki photo lagao — ek tag mein ho gaya.
You are showing your friend a photo of Charminar on your phone. They look at it and instantly know "this is Hyderabad." No explanation needed — the image speaks.
HTML images work the same way. One <img> tag and your page goes from boring text to visual storytelling. Biryani photos, restaurant logos, Charminar shots — images make your page come alive.
The <img> tag is self-closing — no </img> needed.
- <img> — The photo frame. Self-closing tag, no </img> needed.
- src — Where the image file lives. Local path or URL.
- alt — What the image shows. Critical for accessibility and SEO.
- width/height — Display dimensions. Prevents page jumping when image loads.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hyderabad Photo Gallery</title>
</head>
<body>
<h1>Hyderabad Photo Gallery</h1>
<!-- Basic image with alt and dimensions -->
<img src="charminar.jpg"
alt="Charminar illuminated at night"
width="600" height="400"
loading="eager">
<!-- Figure with caption -->
<figure>
<img src="golconda.jpg"
alt="Golconda Fort light show"
width="600" height="400"
loading="lazy">
<figcaption>Golconda Fort — evening light show</figcaption>
</figure>
<!-- Image as clickable link -->
<a href="https://paradisebiryani.com" target="_blank">
<img src="paradise.jpg"
alt="Visit Paradise Biryani website"
width="600" height="200"
loading="lazy">
</a>
</body>
</html>
<img src="..."Opening — self-closing, no end tagsrc="photo.jpg"Image file path — local or internet URLalt="description"Alternative text — for accessibility and SEOwidth="600"Display width — prevents layout shiftloading="lazy"Lazy load — only when user scrolls nearJust like a photographer chooses different lenses for different shots — wide angle for landscapes, macro for close-ups — HTML has different approaches for different image needs.
Pro tip: Images are the heaviest part of any webpage. A single unoptimized image can slow your page by 2-3 seconds. Always optimize — use WebP, add width/height, and lazy load below-fold images.
Build a simple photo gallery page for Hyderabad landmarks using different image concepts.
Open VS Code. Create a new file — name it hyderabad-gallery.html
Use the starter code below and build your gallery:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hyderabad Photo Gallery</title>
</head>
<body>
<!-- h1: Gallery title -->
<!-- 3 images with alt, width, height -->
<!-- 1 figure with figcaption -->
<!-- 1 image wrapped in <a> link -->
<!-- loading="lazy" on images 2 and 3 -->
</body>
</html>
Complete these:
src="https://placehold.co/600x400?text=Charminar"Done — Key Points:
- ✅
<img>is self-closing — no </img> needed - ✅
src= image location,alt= image description - ✅ Always add alt text — accessibility + SEO
- ✅ Always add width/height — prevents layout shift
- ✅ Use WebP format — 30% smaller than JPG
- ✅ Use loading="lazy" for below-fold images
Want to track your progress?
Log in to save your place and pick up where you left off.
Progress track karna chahte ho?
Login karo apni progress save karne ke liye aur jahan chhoda tha wahan se shuru karo.
Login