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.

In shortMost problems are missing end tags, missing quotes, wrong nesting or wrong file paths.

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

Find and fixPage looks oddValidate HTMLFix the errorCheck again
Find and fix

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
Mistake 1: forgot the closing tagTry it Yourself

Add the missing </p>.

Mistake 2: missing quotesTry it Yourself

Values with spaces need quotes. Fix: class="big link".

Mistake 3: wrong nestingTry it Yourself
Mistake 4: no alt textTry it Yourself

Add alt="...".

Mistake 5: duplicate idsTry it Yourself

Ids must be unique. Use a class instead.

Mistake 6: block inside inlineTry it Yourself

Use a div or a section as the outer element.

Mistake 7: p inside pTry it Yourself

A paragraph cannot hold another paragraph. The browser splits them.

Mistake 8: using br for spacingTry it Yourself

Use CSS margin: margin-bottom: 30px.

Mistake 9: table for layoutTry it Yourself

Use flexbox or grid for layout.

Mistake 10: skipping the doctypeTry it Yourself

Add <!DOCTYPE html>.

Mistake 11: wrong file pathTry it Yourself

Case and folder names must match exactly.

Mistake 12: label not connectedTry it Yourself

Fix with for="n" on the label.

Mistake 13: button inside form submitsTry it Yourself

Add type="button" if it should not submit.

Mistake 14: bad entityTry it Yourself

Write &lt; and &amp;.

Mistake 15: image without sizeTry it Yourself

Add style="max-width:100%".

Quick quiz

1. Two elements with the same id is

2. A p inside a p

3. Using br for spacing is

My notes
Ask a question about this lesson