FormatterHQ

HTML Validator

Check HTML structure: unclosed or mis-nested tags, stray closing tags, duplicate IDs and attributes, images without alt text and obsolete elements.

Input HTML
Output TEXT
Ready.

How to use the HTML Validator

  1. Paste your HTML into the Input editor, or use Sample, Upload file or Load URL to check a page’s markup.
  2. Press Validate; the check updates automatically as you edit.
  3. Review errors (structure problems) and warnings (accessibility and best-practice notes), each with a line and column.
  4. Fix the markup and validate again; Copy or Download keeps the report.

What this HTML validator checks

This HTML validator focuses on the structural mistakes that cause real rendering bugs: tags that are opened but never closed, closing tags in the wrong order, stray end tags, duplicate attributes and duplicate IDs. It walks through your markup, keeps track of open elements the way a browser does, and reports each problem with its line and column. It understands HTML's rules for void elements (<img>, <br>, <input>), raw-text elements (<script>, <style>) and elements whose end tags are optional (<p>, <li>, <td>).

Example

<!DOCTYPE html>
<html>
<body>
<div id="main"><section><p>Hello <b>world</p></section>
<img src="a.png">
<div id="main"></div>
</body>
</html>
3 error(s). Line 4, column 1: <div> is not closed before </body>
Line 4, column 34: <b> is not closed before </p>
Line 6, column 1: Duplicate id "main"

The <b> opened inside the paragraph is never closed, the outer <div> is never closed, and the ID main is used twice. Once these errors are fixed, the validator also reports the warning that <img> is missing an alt attribute.

Errors and warnings

Errors (structure)

  • Unclosed elements: <div>, <span>, <section> and others that must be closed. Elements with optional end tags, like <li> and <p>, are closed implicitly as browsers do.
  • Mis-nesting: <b><i>text</b></i> closes elements in the wrong order.
  • Stray closing tags with no matching opening tag.
  • Duplicate attributes on one element, such as two class attributes, where browsers keep only the first.
  • Duplicate IDs, which break getElementById, label for links and fragment anchors.
  • Malformed tags: a tag missing its >, an unclosed attribute quote, an unclosed comment, or a <script> that never ends.

Warnings (best practice)

  • Missing alt on images, needed by screen readers and shown when images fail to load. Use alt="" for purely decorative images.
  • Obsolete elements such as <center>, <font> and <marquee>; use CSS instead.
  • Closing tags on void elements (</br>), and self-closing syntax on normal elements (<div/>), which browsers ignore, so the element stays open.
  • Missing <!DOCTYPE html> in a full document, which puts browsers into quirks mode.

Why these errors matter

Browsers never refuse to render HTML; they repair it. An unclosed <div> is closed at some later point chosen by the parsing algorithm, which can pull following content into the wrong container and break a layout or a CSS grid far from the actual mistake. The self-closing <div/> trap is common in markup converted from JSX or XML: the / is ignored, so everything after it becomes a child of that div. Structural validation makes these repairs visible.

Scope and limits

This is a fast structural checker, not a full implementation of the W3C Nu HTML Checker. It does not verify that every attribute is allowed on an element, that content models are respected (for example, a <div> inside a <p>), or ARIA usage. For a final standards audit of a public page, the W3C service is the reference; for everyday checks while editing templates and emails, this tool gives instant feedback without sending your markup anywhere.

After fixing structure, indent the markup with the HTML Formatter so problems are easier to spot next time, or compress it with the HTML Minifier. To see the page rendered, use the HTML Viewer.

Frequently asked questions

Is this validator the same as the W3C Markup Validation Service?
No. It is a structural checker that runs in your browser. It finds unclosed, mis-nested and duplicate items quickly but does not check every attribute and content model rule the W3C checker covers.
Why is an unclosed p or li not reported?
In HTML the end tags of p, li, td, tr, option and a few others are optional; browsers close them automatically. The validator follows the same rules, so they are not errors.
Is <br/> or <img/> an error?
No. A trailing slash on void elements is allowed in HTML. It is only a problem on normal elements like div, where browsers ignore it and leave the element open.
Can it check PHP or template files?
Template tags are treated as text, so simple templates can be checked. For accurate results, validate the rendered HTML output instead of the template source.
Does the validator send my HTML anywhere?
No. The check runs entirely in your browser; nothing is uploaded.

Last updated September 26, 2026

Related tools

Credit Card Validator Check credit card numbers with the Luhn algorithm, detect Visa, Mastercard, Amex and more, and verify length. Runs 100% locally. CSS Validator Validate CSS online: find unclosed braces, missing semicolons and other syntax errors. Email Address Validator Check email address syntax in bulk and flag typos in popular domains, disposable providers, role accounts and duplicates. IBAN Validator Validate IBANs for 80+ countries with the MOD-97 checksum and country length rules, and see bank code and account parts. ISBN Validator & Converter Validate ISBN-10 and ISBN-13 check digits and convert between the two formats, one or many at a time. JavaScript Validator Check JavaScript for syntax errors online and find the exact line and column of each problem. Phone Number Validator & Formatter Validate phone numbers for 240+ regions and format them as E.164, international and national, with line type detection. TOML Validator Validate TOML files online against the TOML 1.0 spec. Find syntax errors by line and column and see the parsed data as JSON. UUID Validator & Decoder Validate UUIDs/GUIDs and decode version, variant and embedded timestamps for v1, v6 and v7 — many at once. Angular Formatter Format Angular component templates with structural directives, bindings and pipes. BBCode to HTML Converter Convert forum BBCode such as [b], [url], [quote], [list] and [code] into clean, safe HTML markup instantly. BBCode Viewer Preview BBCode forum posts before publishing: bold, colours, links, quotes, lists, code and spoilers rendered live.