HTML validator — find unclosed tags, stray end tags and duplicate ids

Paste a page or a fragment and the validator lists structural problems, such as unclosed tags, stray end tags, duplicate ids and images without alt text, with the line and column of each one.

Live demo · real result from this tool
Errors3
Warnings
4

Issues

LineColumnSeverityMessage
11warning<html> has no lang attribute (needed by screen readers and translation).
11warningNo <meta charset="utf-8"> in the document.
615error<b> (line 6) is not closed before </div> on line 9.
73warning<img> without alt text. Describe the image, or use alt="" if it is decorative.
83errorDuplicate id “main” (first used on line 5).
101warning<center> is obsolete in HTML5; use CSS or a modern element instead.
111errorStray end tag </p> with no matching open element.

Processed on your device — nothing is uploaded.

How to use the HTML validator

  1. Paste your markup into the HTML box. The sample shows a page with several typical mistakes.
  2. Read the summary: the number of Errors and Warnings.
  3. Work through the Issues table. Each row gives the Line, Column, Severity and a plain message.
  4. Fix the first error first, then check again. One unclosed tag can cause a second message further down.
  5. Download the table as html-issues.csv if you want to share the list.

What it does and when to use it

Browsers never refuse broken HTML. They repair it silently, and the repair is not always what you meant: a paragraph closes early or a style hits the wrong element. This tool shows where that repair would happen.

Use it before you paste markup into a CMS or an email template, and after hand-editing a page. Messy exports from word processors are easier to check after the HTML Cleaner has removed the clutter. If the problem is hard to see, run the code through the HTML Formatter first; wrong indentation often points at the same line the validator reports.

What it checks

  • Errors: unclosed or mis-nested elements, stray end tags, end tags on void elements such as br, unclosed tags or comments, duplicate attributes, duplicate ids, ids with spaces, a link inside a link.
  • Warnings: img without alt, obsolete tags such as center or font, unknown tag names, li outside a list, td outside a table, a label for that matches no id, and a missing doctype, lang, title or charset.

How it works

The tool reads your HTML with its own tokenizer and keeps a stack of open elements, the way a browser parser does. It applies the optional end-tag rules, so <li>a<li>b is valid. Content inside svg and math is skipped, and tag names with a hyphen count as custom elements. Nothing is uploaded; the check runs in your browser.

Worked examples

A link inside a link and a broken label. This list puts one link inside another, and the label points to mail while the input’s id is email:

<ul>
  <li><a href="/a">One <a href="/b">two</a></a>
</ul>
<label for="mail">Email</label><input id="email">

Result: 1 error and 1 warning. Line 2, column 24: <a> inside another <a> is not allowed. Line 4: <label for="mail"> points to an id that does not exist. A broken label also means a screen reader will not announce the field’s name.

A div inside a paragraph. <p>Intro<div>Box</div></p> gives Stray end tag </p> with no matching open element. The div closed the paragraph automatically.

Optional end tags. <table><tr><td>a<td>b</table><p>Fine<p>Also fine returns “No problems found”, because every missing end tag here is allowed.

Limits and tips

  • It does not check attribute values, required attributes or ARIA roles. To review attributes, list them with the HTML Attribute Extractor.
  • An unclosed inline tag, such as a b near the top, is reported where it was opened, with the line of the end tag that exposed it.
  • Fix duplicate ids first. Labels, anchors and scripts that use the id will only ever find the first element.

Frequently asked questions

Is this the same as the W3C validator?
No. It is a structural checker. It covers tags, nesting, ids, alt text, obsolete elements and basic document checks, but not every rule in the HTML specification, such as which attributes each element allows. The success message says this too. For a full conformance check, run the W3C Nu checker as well.
Why does it call my closing p tag "stray"?
A p element cannot contain block elements such as div. When the browser meets the div, it closes the open paragraph for you, so the later closing p tag has nothing to close. Use a div as the wrapper, or keep the paragraph text and the box separate.
Why are missing closing li or td tags not reported?
HTML lets you leave out the end tag of li, p, td, tr, option and a few other elements. The browser closes them when the next sibling starts. The validator follows the same rules, so it only reports end tags that are really missing.
Can I check a fragment instead of a full page?
Yes. The document checks for a doctype, lang, title and charset only run when your HTML contains an html tag. A fragment from a template or a CMS block gets just the tag, nesting, id and alt checks.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close