Skip to content

HTML Validator & Checker

Check HTML for unclosed and misnested tags, stray closing tags, duplicate IDs and attributes, and missing alt text, with line and column numbers.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is HTML Validator?

This HTML validator checks your markup for the errors that browsers silently fix. Browsers almost never reject HTML: the HTML Standard defines how to recover from unclosed tags, misnested elements and stray characters, so a broken page still renders, but often not the way you intended. A missing </div> can swallow the rest of the layout, and a <div> inside a <p> closes the paragraph early.

Paste an HTML snippet or a full document and the validator lists every problem it finds with its line and column, split into errors (markup the browser has to repair) and warnings (accessibility and best-practice issues such as images without alt text). If nothing is wrong, you get a clean result with the number of elements checked.

How to use HTML Validator

  1. Paste your HTML snippet or full document into the input box.
  2. Read the summary: the number of errors and warnings, or a confirmation that none were found.
  3. Go through the list; each issue shows its line and column, such as an unclosed <section> or a duplicate id.
  4. Fix the markup and the list updates as you type.

Key features

  • Finds unclosed, misnested and stray closing tags
  • Flags duplicate IDs, duplicate attributes and nested links
  • Warns about missing alt text, obsolete tags and a missing doctype, lang or title
  • Line and column for every issue
  • Understands void elements, optional end tags, script and style content, and inline SVG
  • Runs locally; your markup is not uploaded

Common use cases

  • Sanity-checking HTML snippets before pasting them into a CMS
  • Checking generated markup from templates and static site generators
  • Reviewing HTML email templates
  • Learning how browsers recover from invalid HTML
  • Preparing markup for a full W3C validation pass

Technical details & standards

The validator tokenizes the markup and tracks open elements the way an HTML parser does, following the HTML Standard: void elements such as <img>, <br> and <input> never need a closing tag, optional end tags (</li>, </p>, </td>, </option> and others) are closed implicitly, and the contents of <script>, <style>, <textarea> and <title> are read as raw text. Inline SVG and MathML follow XML-style rules, so self-closing tags are allowed there.

Errors: elements that are never closed, closing tags in the wrong order (misnesting), closing tags with no matching start tag (including a stray </p> after a block element closed the paragraph), end tags for void elements, self-closing syntax on non-void elements such as <div/>, duplicate id values, duplicate attributes on one element, links nested inside links, and unterminated comments or attribute values. Warnings: images without an alt attribute, obsolete elements such as <center> and <font>, and, for full documents, a missing <!DOCTYPE html>, lang attribute or <title>. It does not check every content-model rule of the HTML Standard; for a full conformance report, also run the W3C Nu HTML Checker.

Frequently asked questions

Why does invalid HTML still display in the browser?

The HTML Standard requires browsers to recover from errors in a defined way rather than stop rendering. That keeps pages working, but the browser's fix may not match your intent, for example closing a paragraph early when it meets a div.

What are the most common HTML errors?

Unclosed or misnested tags, a block element such as <div> inside a <p>, duplicate id values, images without alt attributes, and a missing <!DOCTYPE html> declaration. This validator reports each of them with its position.

Is a stray </p> really an error?

Yes. When a block element such as <div> or <ul> starts inside a paragraph, the browser closes the paragraph automatically, so the </p> you wrote later has nothing to close. The browser then inserts an empty paragraph, which can add unexpected spacing.

How is this different from the W3C validator (Nu Html Checker)?

The W3C Nu HTML Checker implements every rule of the HTML Standard, including which elements may contain which. This tool focuses on the structural errors that change how a page renders and on common accessibility warnings, checks as you type, and never sends your markup to a server.

Does HTML validity affect SEO?

Search engines handle imperfect HTML well, so small errors rarely hurt rankings directly. Broken structure can still hide content, break structured data or harm accessibility, which is why validating important templates is worthwhile.

Why does it warn about a missing html lang attribute?

The lang attribute, such as <html lang="en">, tells screen readers which language and pronunciation to use, lets browsers offer translation and hyphenate text correctly, and is required by WCAG success criterion 3.1.1 (Language of Page). Use a language code such as en, en-US, hi or fr.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More validators & checkers tools

View all