12 Common HTML Mistakes Beginners Make (And How to Fix Them)

Everyone writes bad HTML when they're learning — that's normal. What matters is recognising the patterns so you can stop repeating them. Here are the twelve mistakes I see most often in code reviews.
- Missing the <!doctype html> declaration
- Nesting block elements inside <a> incorrectly
- Using <br> for spacing instead of CSS margins
- Skipping the alt attribute on images
- Using multiple <h1> tags for visual size
- Forgetting <label> on form inputs
- Wrapping everything in <div>
- Using <i> and <b> instead of <em> and <strong>
- Inline style attributes everywhere
- Not closing self-closing tags consistently
- Tables for layout (it's 2026!)
- Missing viewport meta tag
The viewport meta everyone forgets
<meta name="viewport" content="width=device-width, initial-scale=1" />Without it, mobile browsers render your page at 980px wide and shrink it — making text unreadable on phones.
Frequently asked questions
Why is alt text so important?
Screen readers announce it to blind users, and search engines use it to understand images for image search.
External references
Enjoyed this article?
Share it with a fellow developer or explore more tutorials in our blog.
More articles