What the HTML Validator does
The HTML Validator scans markup for unclosed and mismatched tags, knowing which elements are void (such as br, img and input) and never need closing. It is a fast structural check, not a full W3C conformance test.
HTML Validator examples
The built-in sample
Input
<div><h1>Hello</h1><p>Some <b>text</b></p></div>Output
No unclosed or mismatched tags found.This is the input that the Load sample button fills in.
Void elements need no closing tag
Input
<div><p>one<br><img src="a.png" alt=""></p></div>Output
No unclosed or mismatched tags found.br and img are void elements, so they are not expected to be closed.
Each output was produced by running this tool on the input above it.
How it works
The tool scans every tag in order and keeps a stack of open elements. A closing tag must match the most recently opened element, and any element left open at the end is reported. Void elements (area, base, br, col, embed, hr, img, input, link, meta, source, track, wbr) and self-closing tags are skipped.
Details and limits
- HTML lets you omit some closing tags, such as
</li>and</p>. This tool does not apply those rules, so<ul><li>one<li>two</ul>is reported even though browsers accept it. - Text inside
scriptandstyleis scanned like markup. A comparison such asa<bin inline JavaScript can be mistaken for a tag. - Only the first problem is reported. Fix it and run the check again.
- Tag names are compared without regard to case.
Common errors
| Message or symptom | What it means |
|---|---|
| Unexpected closing tag | A closing tag does not match the most recently opened element. |
| Unclosed element | An element such as a div or li is never closed. |
Worked example: Catching a mismatched closing tag and an unclosed div
Suppose you paste this 6-line navigation snippet into the HTML Validator:
1: <header class="top-bar">
2: <nav aria-label="Main">
3: <img src="/logo.svg" alt="Brand">
4: <a href="/pricing/">Pricing</span>
5: </nav>
6: </section>
- Line 3 (
<img>): Passed—imgis a valid HTML5 void element and requires no</img>closing tag. - Line 4 (
<a>...</span>): Error reported—found closing tag</span>, which does not match the currently open<a href="/pricing/">tag opened on Line 4. - Line 6 (
</section>): Error reported—found closing tag</section>, which does not match<header class="top-bar">opened on Line 1.
Limits and what this tool cannot do
- Checks tag nesting and balance, not full W3C Nu HTML DTD/ARIA conformance: This validator parses open/close tag stacks and HTML5 void rules (
br,img,input,meta,link,hr). It does not validate CSS property names, check whetheraria-*attributes are allowed on specific roles, or verify thathreflinks resolve. - Implicitly closed HTML5 tags (
<p>,<li>,<td>): Even though browsers auto-close an unclosed<p>when they encounter the next<p>or<div>, this strict tag-matcher flags unclosed<p>and<li>tags so your markup stays explicit and clean.
Questions
Is this a full HTML validator?
No. It checks one thing: that tags are closed and nested correctly. It does not check attributes, required elements or which elements may contain which.
Do I need to put a self-closing slash (
or
) on HTML5 void elements?
No. Both <br> and <br /> are accepted by HTML5 parsers and by this validator. The trailing slash is only mandatory if you are writing strict XML/XHTML.
Why did a missing quote inside an attribute cause tag errors on later lines?
If you write <a href="/home>Home</a> without the closing quotation mark after /home, the HTML tokenizer treats >Home</a> as part of the href string until it hits the next " several lines below.
Does this validator support custom web components like ?
Yes. Any hyphenated custom element (<my-widget>...</my-widget>) is treated as a standard container tag that requires a matching closing tag.