HTML Lists: 5 Critical Mistakes Killing Your UX
Fix 5 critical HTML Lists mistakes killing your UX! Master, & tags for scannable content and better accessibility.…
Read more →Fix 7 deadly HTML Images mistakes killing your site! Master tag optimization for faster loading, better SEO & accessibility.
Remember those childhood afternoons flipping through National Geographic, utterly lost in vibrant photos of jungles and deserts? That’s the power of imagery – and on the web, it all starts with a humble <img> tag. Today, we’re ditching dry tutorials and diving into the art of visual storytelling. I’ll share my cringeworthy fails (like the time I uploaded a 12MB family reunion photo that took 3 minutes to load) so you can skip straight to pro-level.
Ready to make your site visually irresistible? Let’s paint with pixels. 🎨
Pop quiz: What’s the only HTML element that doesn’t need a closing tag? Bingo – it’s our hero <img>. Here’s the basic spell:
<!-- Replace "your-image.jpg" with your visual masterpiece -->
<img src="your-image.jpg" alt="A majestic squirrel wearing a tiny crown"> Why this works like magic:
src is your image’s home address (like telling Uber where to pick up your pixels)alt is the emergency narrator when:
<img> is a lone wolf (unlike chatty <div> tags)Pro tip from my fails: Name files clearly! squirrel-king.jpg beats DSC_34892.JPG – future-you will weep tears of gratitude.*
Option 1: Local files (your computer’s basement)
<img src="images/my-dog-judging-you.jpg" alt="Shiba Inu side-eyeing camera"> → Organize in folders like /images or /assets unless you enjoy digital hoarding
Option 2: Web URLs (borrow responsibly!)
<img src="https://placedog.net/500" alt="Random doggo awaiting your commands"> ⚠️ Crucial warning: External links can break! That hilarious meme today might be a 404 error tomorrow. Host your own images for anything important.
True horror story: I built a client site using free stock photos from stock images site. The domain expired. Suddenly, their homepage featured 27 broken image icons.
This isn’t SEO fluff – it’s lifeline content for:
The Good, Bad & Ugly:
❌ <img src="pizza.jpg" alt="image"> <!-- Worthless -->
❌ <img src="pizza.jpg" alt="pizza"> <!-- Still useless -->
✅ <img src="pizza.jpg" alt="Gooey pepperoni pizza with melted cheese"> <!-- Mouth-watering! --> When to use empty alt text:
<!-- Pure decoration - no meaning needed -->
<img src="divider-squiggle.png" alt=""> Accessibility test: Close your eyes. Have a friend read your alt text. Would you understand the image?
There are two ways to resize – one safe, one dangerous:
The Safe Method (CSS):
<img src="portrait.jpg" alt="Me at 3AM debugging"
style="width: 300px; height: auto;"> → auto maintains proportions → no distorted nightmare fuel
The Crime Scene (HTML attributes):
<!-- Turns your kitty into a furry pancake -->
<img src="cat.jpg" width="400" height="100" alt="Feline abomination"> Golden rule: Always constrain just ONE dimension (width OR height), never both.
Mobile users hate horizontal scrolling more than lukewarm coffee. Fix it with:
<img src="skyline.jpg" alt="City lights"
style="max-width: 100%; height: auto;"> What this tells browsers:
My mobile disaster: Used a fixed-width image in a responsive layout. On phones, it required sideways scrolling. My client texted: “Did you design this for ants?”
Add secret tooltips (use like hot sauce – sparingly):
<img src="book.jpg" alt="Mystery novel"
title="Chapter 1: The Missing Semicolon"> Make images clickable (wrap in <a>):
<a href="product-details.html">
<img src="limited-edition-sneakers.jpg" alt="Glow-in-the-dark kicks">
</a> → Perfect for galleries, product listings, or “enlarge image” features
| Format | Best For | Kryptonite | Real-World Use |
|---|---|---|---|
| JPG | Photos, gradients | Transparency | Blog images, product shots |
| PNG | Logos, text-heavy | File size | Icons, graphics with text |
| GIF | Memes, simple anims | Limited colors | Reaction gifs, loading spinners |
| SVG | Icons, illustrations | Complex photos | Logos, icons that need infinite scaling |
| WebP | Everything! | Legacy browsers | Modern sites where performance matters |
My cheat sheet:
When images ghost your page (wrong path, deleted file):
<!-- Bad -->
<img src="missing.jpg" alt=""> <!-- Silent failure! -->
<!-- Good -->
<img src="oops.jpg" alt="Failed to load: Cat playing keyboard"> Pro damage control:
img {
background: #f8f8f8 url("placeholder.svg") center no-repeat;
border: 1px dashed #ddd;
} → Shows a placeholder while loading
→ Dashed border indicates “should be image here”
Build this responsive gallery in 10 minutes:
<div style="display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;">
<!-- Taco -->
<a href="taco-recipe.html">
<img src="tacos.jpg" alt="Rainbow veggie tacos"
style="width: 200px; border-radius: 8px;">
</a>
<!-- Cake -->
<a href="cake-recipe.html">
<img src="choco-cake.jpg" alt="Molten chocolate lava cake"
style="width: 200px; border-radius: 8px;">
</a>
<!-- Add your 3rd food masterpiece here -->
</div> In our scroll-happy world:
→ Visual content gets 94% more views than text-only
→ Pages with images keep visitors 72% longer
→ Product listings with photos convert 35% better
→ Infographics are shared 3x more than articles
But here’s the real secret: Great imagery isn’t about decoration – it’s about creating instant emotional connections. A single photo of a person smiling can make your site feel 10x more human than any “About Us” page.
“We don’t remember websites; we remember how they made us feel.
And nothing tugs heartstrings faster than the right image.”
*- My designer friend after testing 50 landing pages*
Tinker dare: Try <img> without src. What happens? The browser renders… nothing. But add an alt and watch the magic!
(Spoiler: Alt text shows only when src fails. This is why empty src="" + good alt creates intentional text placeholders!)
Practice what you learned
Reading is step one. Open this lesson's starter code in the editor, finish it, and you've really learned it.
<!-- Replace "your-image.jpg" with your visual masterpiece --> <img src="your-image.jpg" alt="A majestic squirrel wearing a tiny crown">
Fix 5 critical HTML Lists mistakes killing your UX! Master, & tags for scannable content and better accessibility.…
Read more →Master HTML Definition Lists: Fix 5 critical mistakes ruining glossaries & FAQs. Pro styling & accessibility techniques for…
Read more →HTML Tables: Fix messy data fast! Build clean grids for pricing/schedules. Pro CSS styling + mobile tricks included.
Read more →Arm yourself with step by step tutorials, expert tips, and insider tools to conquer any coding project - subscribe now.