1. Home
  2. Developer
  3. HTML Validator

HTML Validator

Find tag mismatches, duplicate ids and basic accessibility issues.

For every format and option in one place, use Code Formatter and Checker →

Runs in your browser · No upload
Errors
6
Warnings
4
Info
1
Elements
16
ids
1
Lines
18
HTML input
TypeLocationMessageCode
Warning1:1There is no <!DOCTYPE html>, so browsers may use quirks mode.<html>
Warning1:1The <html> element has no lang attribute. Example: <html lang="en"><html>
Info1:1There is no <meta charset="utf-8">.<html>
Error7:3<div> is never closed. A </div> is needed.<div id="box">
Warning9:5Opening <div> automatically closes the open <p>. A <p> cannot contain block elements.<div id="box">Second box</div>
Error9:10id="box" is already used on line 7. An id must be unique in the document.<div id="box">Second box</div>
Error10:3</p> has no matching <p>.</p>
Error11:3This <img> has no alt attribute. Use alt="" for a decorative image.<img src="logo.png">
Warning12:3This <a> has no text or image, so a screen reader has no name to read. Add content or aria-label.<a href="/more"></a>
Error17:17</b> appears before <i> was closed. The tags overlap.<span><b>Bold <i>italic</b></i></span>
Error17:30</i> has no matching <i>.<span><b>Bold <i>italic</b></i></span>

This tool applies its own rules for tag matching, ids, nesting and basic accessibility. It does not check allowed attributes per element or the full content model like the W3C Nu validator does.

Your HTML is checked in this browser and never uploaded.

How to use

  1. Paste the HTML you want to check. The box starts with a sample that contains several problems so you can see the result table straight away.
  2. Read the errors, warnings and info with their line and column. The right-hand column shows the code on that line.
  3. Fix errors first. The result refreshes as you edit. Use the checkboxes to show only the types you want.

You can paste a full document (with <html>, <head>, <body> or a doctype) or just a fragment. Fragments are not held to document-level rules such as doctype, lang and title.

What is checked

Group Checks
Tag matching Unclosed elements, end tags with no start tag, overlapping tags like <b><i></b></i>, end tags on void elements such as </br>, ignored self-closing like <div/>
Syntax Unclosed comments, tags and quotes, duplicate attributes on a tag, missing space between attributes, a bare < in text
ids Duplicate ids, empty ids, ids containing spaces, <label for> pointing to a missing id
Nesting <li> outside a list, <td> outside <tr>, an <a> inside an <a>, a <div> inside a <span>, block elements inside <p>
Elements and attributes Non-standard elements, obsolete elements (font, center) and attributes (align, bgcolor, border on tables)
Basic accessibility img alt and src, empty links and buttons, inputs without labels, iframe title, skipped heading levels, multiple h1
Document doctype, lang, title, meta charset

Elements whose end tag may be omitted (li, p, td, tr, option and so on) are not reported when left open. <ul><li>a<li>b</ul> is valid HTML.

Sample result

The sample in the box contains these problems, and checking it gives 6 errors, 4 warnings and 1 info:

  • Line 7: <div id="box"> is never closed (error)
  • Line 9: opening <div> closes the <p> automatically (warning), and the id box is reused (error)
  • Line 10: </p> has no match because the p was already closed (error)
  • Line 11: <img> has no alt (error). Line 12: the <a> has no content (warning)
  • Line 17: <b><i></b></i> overlaps (2 errors)
  • Whole document: no doctype and no lang (warnings), no charset (info)

Limits of this checker

This is not a full validator such as the W3C Nu HTML Checker. It does not check the allowed values for each attribute, the complete list of children allowed in a <table>, or the exact use of ARIA roles. It is for catching the mistakes people make most often while writing. Before release, also run an official validator or the accessibility audit in your browser’s developer tools.

Browsers do not report HTML errors. They quietly repair the markup, so a page can look fine while the source has problems. Some warnings here describe repairs the browser already makes, so the page may look correct anyway.

Frequently asked questions

How does it find unclosed tags?

It keeps a stack of open tags and matches each end tag against it. With no match you get “unclosed element” or “end tag with no start tag”, and if other elements are still open in between you get an overlapping-tags error, each with line and column.

Why are duplicate ids a problem?

getElementById, #id anchor links and <label for> all assume one element per id. With duplicates only the first is found, so scripts and links go to the wrong place.

Is alt really required on images?

Yes. Screen readers read it and it is shown when the image fails to load. For decorative images use alt="" so screen readers skip them. Leaving the attribute out entirely is an error.

Does an empty result mean my HTML is perfect?

No. It only means nothing was found within the scope described under the limits above.

Related tools: HTML Beautify and Minify, XML Validator, HTML Entity Converter, Meta Tag Generator, CSS Beautify and Minify.

Your HTML is checked in your browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.