Home / Learn HTML / Common HTML Mistakes and How to Fix Them
Common HTML Mistakes and How to Fix Them
The mistakes every beginner makes. Spot them in the editor, then fix them.
About this lesson
Most HTML bugs come from a small set of mistakes: unclosed tags, wrong nesting, missing alt text, duplicate ids and wrong paths. Learn to spot them quickly; each example below shows the mistake and the fix.
Theory in plain words
What it is
Common mistakes are errors beginners repeat: unclosed tags, missing alt, wrong nesting, duplicate ids.
Why we use it
Knowing them saves hours of debugging.
How it works
Browsers repair broken HTML silently, so the page may look fine but behave wrong. Validators show the real problem.
Where it is used
- Debugging
- Code review
- Interviews
Add the missing </p>.
Values with spaces need quotes. Fix: class="big link".
Add alt="...".
Ids must be unique. Use a class instead.
Use a div or a section as the outer element.
A paragraph cannot hold another paragraph. The browser splits them.
Use CSS margin: margin-bottom: 30px.
Use flexbox or grid for layout.
Add <!DOCTYPE html>.
Case and folder names must match exactly.
Fix with for="n" on the label.
Add type="button" if it should not submit.
Write < and &.
Add style="max-width:100%".
Quick quiz
1. Two elements with the same id is
Ids must be unique.
2. A p inside a p
The browser splits them.
3. Using br for spacing is
br is for line breaks only.