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.

Reviewed by the thecalcu.com team · Last updated July 2, 2026

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.

Why Use an HTML Validator?

HTML errors are silent. A missing </div> does not throw an error, the browser guesses where the element should end, and the guess is sometimes right and sometimes wrong. The result is layout breaks that appear only in certain contexts, or accessibility issues that only become apparent when testing with a screen reader.

Common scenarios:

  • Writing a reusable HTML component by hand and wanting to confirm tag structure before embedding it in a template
  • Cleaning up HTML copied from a Word document or Google Docs export, which often contains unclosed or mismatched tags
  • Checking an HTML email template before sending, email clients have stricter and more varied parsing than browsers
  • Debugging a layout issue by confirming the tag structure is correct before investigating CSS

Who Should Use This Validator?

Frontend developers building HTML components by hand, catch structural issues early before they produce layout bugs or accessibility problems downstream.

Email developers and marketers building HTML email templates, where well-formed markup matters more than in browser HTML because email client parsers are far less forgiving.

Content editors and CMS users who paste HTML snippets into a content management system and want to confirm the markup is structurally sound before publishing.

QA engineers testing pages for accessibility and layout consistency, structural HTML errors can break ARIA roles and screen reader navigation.

For a stricter, full-compliance check, use the W3C Markup Validation Service alongside this tool.

What Insights Does the HTML Validator Give You?

When the HTML is valid (no structural errors detected), the tool confirms no unclosed tags or mismatched nesting were found, and adds a note clarifying the scope, this is a structural check, not a full W3C compliance audit.

When the HTML is invalid, the tool lists each structural issue:

  • Unclosed tags, lists every element that was opened but never closed, in the order they were opened
  • Unexpected closing tags, a closing tag appears where a different closing tag was expected, indicating crossed nesting
  • Void element closing tags, </br>, </img>, etc., which are never valid

Each issue is listed as a separate bullet in the details panel.

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>.

Related Tools

You may also find these useful: Disposable Email Domain Validator.

Frequently Asked Questions

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.
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.
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.
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.
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.
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.
Nothing is uploaded. 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.
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.
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.
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.
Also known as
check htmlvalidate html snippethtml tag checkerunclosed tag checkerhtml syntax checkerhtml well-formedness