Veda Bites are swipeable micro-lessons — each one teaches exactly one
idea. The bites below come from this kit — swipe through them in the app.
💡 Key Idea
The <img> Tag Is a Void Element
One tag, no closing — that's how images load.
HTML images are inserted with the <img> tag. It is a void (self-closing) element — it has no closing tag and no content inside it.
↳ <img> is self-contained: it references an external file, not inline content.
📖 Definition
Two Attributes You Cannot Skip
src and alt — the non-negotiables.
↳ Without src, nothing loads; without alt, the image is inaccessible.
⭐ Important Fact
alt Text Serves Three Purposes
alt is not just a fallback.
↳ alt is accessibility, fallback, and SEO in one attribute.
⚖️ Comparison
Absolute vs Relative Image Paths
Where does the browser look for your image?
↳ Use relative paths for your own files; absolute URLs for external images.
⭐ Important Fact
Common Web Image Formats
JPG, PNG, GIF, SVG, WebP — pick wisely.
↳ Match format to content: JPEG for photos, PNG/SVG for graphics.
💡 Key Idea
Sizing Images: width and height
Control size without breaking layout.
Setting width and height reserves space before the image loads, preventing layout shift.
↳ Always set width/height to avoid content jumping as images load.
⚠️ Common Mistake
Stretching Images Distorts Them
Don't squash your images.
↳ Preserve aspect ratio by scaling one dimension or using CSS.
✅ Best Practice
Make Images Responsive
One image, every screen size.
↳ max-width: 100% + height: auto = responsive images with one rule.
✏️ Example
Image as a Link
Click the picture, go somewhere.
↳ Wrap <img> in <a> to create image links.
🚫 Warning
Never Use alt for Decorative Images
Sometimes empty alt is correct.
↳ Decorative images get alt="" — meaningful images get real descriptions.
🎯 Exam Tip
Exam Favourite: src vs alt
Two attributes, one common trap.
↳ src loads the image; alt describes it when it can't load.
🧠 Memory Trick
Remember: S-A-W-H
Four letters, four attributes.
S-A-W-H: Src, Alt, Width, Height — the four most-used <img> attributes.
↳ S-A-W-H keeps the core <img> attributes in memory.
❓ Did You Know
Images Are Not Inside the HTML File
The HTML only points to them.
The <img> tag does not contain the image — it only references an external file. The browser fetches that file separately over the network.
↳ HTML links to images; it never embeds the pixel data itself.
🌍 Real World
Why alt Text Matters in Real Sites
Accessibility is a legal requirement.
↳ Real-world sites treat alt text as a legal and UX necessity.
🛠️ Application
Using <figure> and <figcaption>
Give your image a caption.
↳ <figure> + <figcaption> pairs an image with its caption semantically.