HTML Validator
DataCheck 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
- Open the HTML Validator on this page.
- Paste your HTML into the HTML Input field — you can paste a full document or an isolated snippet.
- The result badge updates instantly. A green Valid badge means no structural issues were detected.
- If the badge shows Invalid, read the details list — each bullet describes a specific structural error.
- 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.
- 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>.