HomeValidatorsDataHTML Validator

HTML Validator

Data

Check HTML for unclosed tags and mismatched nesting — basic well-formedness validation in your browser. Not a full W3C compliance check. Free, no signup.

What is a HTML?

An HTML Validator checks the structural integrity of HTML markup — specifically whether all non-void elements are properly closed and whether tags are correctly nested. Browser HTML parsers are forgiving by design: an unclosed <div> or a crossed tag nesting like <b><i>text</b></i> is silently corrected rather than flagged as an error. This means structural mistakes in HTML go undetected until they manifest as layout bugs, broken accessibility trees, or rendering inconsistencies across browsers.

This tool uses a stack-based tag matcher to detect the structural issues that the browser's error-recovery algorithm would silently fix. It is not a full W3C specification compliance checker — for that, the W3C Markup Validation Service is the definitive tool. What this tool provides is a fast, in-browser check for the most common hand-writing mistakes: forgotten closing tags, mismatched nesting, and closing tags on void elements like <br> or <img>.

Void elements — <area>, <base>, <br>, <col>, <embed>, <hr>, <img>, <input>, <link>, <meta>, <param>, <source>, <track>, and <wbr> — cannot have closing tags. Writing </br> or </img> is always an error, and this tool flags it.

Validation runs entirely in your browser. No HTML you enter is transmitted or stored. For checking data format (rather than markup structure), see the XML Validator or JSON Validator.

How to use this HTML calculator

  1. Open the HTML Validator on this page.
  2. Paste your HTML into the HTML Input field — you can paste a full document or an isolated snippet.
  3. The result badge updates instantly. A green Valid badge means no structural issues were detected.
  4. If the badge shows Invalid, read the details list — each bullet describes a specific structural error.
  5. Find the corresponding tag in your HTML (search for the tag name), fix the closing tag or nesting order, and paste the corrected HTML back.
  6. Repeat until the Valid badge appears. If there are multiple errors, fix them from top to bottom — an early error often causes cascading false positives.

Formula & Methodology

The tool uses a stack-based tag matching algorithm:

1. Scan the HTML for all opening and closing tags using a regex that captures the tag name and whether it is a closing tag or self-closing.
2. For each opening tag that is not a void element and not self-closing, push the tag name onto a stack.
3. For each closing tag: if it matches the top of the stack, pop it (correct nesting). If it does not match, report an "unexpected closing tag" error. If it is a void element, report a "void element cannot be closed" error.
4. After processing all tags, any names remaining on the stack are reported as unclosed.

Valid example:
html <div>   <p>Hello <strong>world</strong></p> </div> 
Result: No structural issues detected.

Invalid example (unclosed <p>):
html <div>   <p>Hello <strong>world</strong> </div> 
Result: Unclosed tags: <p>.
Frequently Asked Questions
What does this HTML Validator check?
This tool performs a basic structural well-formedness check on HTML snippets — it identifies unclosed tags, mismatched tag nesting, and closing tags applied to void elements (like `<br>` or `<img>`). It does not perform full W3C HTML specification compliance checking. Browser HTML parsers are deliberately lenient and will not surface most structural errors on their own, so this tool uses a stack-based tag matcher to catch the issues that silently degrade your markup.
What is the difference between this and the W3C HTML Validator?
The W3C validator (validator.w3.org) checks full specification compliance — deprecated attributes, missing `alt` text, incorrect element nesting per the HTML5 content model, and dozens of other rules. This tool checks only structural well-formedness: are all non-void tags closed, and are they correctly nested? It is fast and client-side, making it useful for quick snippet checks. For comprehensive compliance validation, use the W3C tool.
What are void elements?
Void elements are HTML elements that cannot have child content and therefore do not have a closing tag. The void elements in HTML5 are: `<area>`, `<base>`, `<br>`, `<col>`, `<embed>`, `<hr>`, `<img>`, `<input>`, `<link>`, `<meta>`, `<param>`, `<source>`, `<track>`, and `<wbr>`. Writing `</br>` or `</img>` is a structural error that this tool will flag.
Why doesn't the browser flag HTML errors itself?
HTML was designed for the web, where documents from millions of authors needed to be rendered — including ones with errors. Browser HTML parsers implement an error-recovery algorithm that silently corrects many structural mistakes (auto-closing unclosed tags, reordering mismatched nesting). This leniency is intentional but means errors go undetected in production. This tool applies stricter checking to catch the issues before they cause layout bugs or accessibility problems.
Can I paste a full HTML page into this tool?
Yes. You can paste a full HTML document (with `<!DOCTYPE html>`, `<html>`, `<head>`, `<body>`) or an isolated snippet. The tool checks the tag structure of whatever you paste — it does not require a full document. Note that `<!DOCTYPE html>` and HTML comments are not processed as tags and will not affect the result.
What is mismatched tag nesting?
Mismatched nesting occurs when a closing tag does not match the most recently opened tag. For example, `<b><i>text</b></i>` — `</b>` closes before `</i>`, crossing the nesting. This is an error in XML but is silently corrected by HTML parsers. This tool detects and reports it as an unexpected closing tag.
Is my HTML stored when I use this tool?
No. The tag structure check runs entirely in your browser using JavaScript. No HTML you enter is sent to a server, logged, or stored. You can safely paste HTML containing internal data or application code.
Does this tool validate CSS or JavaScript inside the HTML?
No. This tool checks HTML tag structure only. CSS within `<style>` tags and JavaScript within `<script>` tags are treated as text content and are not parsed or validated. For CSS and JavaScript validation, use dedicated tools.
What is the most common HTML structural error?
Unclosed `<div>` tags are the most common structural error in hand-written HTML. A missing `</div>` causes the browser to infer where the element ends, which can produce unexpected layout behaviour — especially with floated or absolutely positioned content. The next most common errors are unclosed `<a>` and `<p>` tags.
Can this tool help me fix HTML from a CMS or email template?
Yes. HTML generated by CMS editors, email template builders, or copied from documents often contains structural errors. Paste the HTML output here to identify unclosed or mismatched tags before using it in a campaign or page. For email HTML in particular, well-formed markup is important because email clients have even more varied parsing behaviour than browsers.