HTML Validator
Check HTML for errors right in your browser. Paste code or upload a file to see each problem with its line and rule.
HTML Validator tool
Example
Input: The built-in sample: no lang on html, an img without alt, a b element left open inside a p, a center tag, a section inside the open b and a script with type="text/javascript"
Result: 9 errors, 1 warning. First error: <html> is missing required "lang" attribute (line 2, column 2, rule element-required-attributes).
Real output from html-validate 11.16.0 with this tool's settings. The unclosed b element causes several follow-on errors: closing it with </b> drops the count from 9 errors to 4.
Common Messages and How to Fix Them
| Message | Rule | Fix |
|---|---|---|
| <img> is missing required "alt" attribute | wcag/h37 | Add alt text, or alt="" for decorative images |
| End tag '</p>' seen but there were open elements | close-order | Close inner tags such as b before closing the p |
| <center> is deprecated: use CSS instead | deprecated | Use CSS, for example text-align: center |
| <section> element is not permitted as content under <b> | element-permitted-content | Keep block elements out of inline ones such as b |
| "type" attribute is unnecessary for javascript resources | script-type | Remove type="text/javascript" |
| <html> is missing required "lang" attribute | element-required-attributes | Write <html lang="en"> (or your language) |
| <button> is missing recommended "type" attribute | no-implicit-button-type | Add type="button" or type="submit" |
Messages exactly as html-validate 11.16.0 reports them with this tool's settings.
- Paste your HTML into the box, or click Upload .html file to load a file from your device.
- Click Validate HTML. The first check loads the validator, which takes a moment.
- Work through the errors first: each shows the line, column, rule name and the code with the problem highlighted.
- Click a rule name to read why it matters and how to fix it.
- Review the warnings, then click Copy report to save the full list as text.
Checking HTML Against the Standard
Paste HTML or upload an .html file, and this validator lists every error and warning. Each one comes with its line, column, the rule that flagged it and the code around it. It runs the open-source html-validate library inside your browser, so your code is never uploaded.
html-validate is a linter-style validator. It checks your markup against the rules of the HTML standard, such as which elements may sit inside others and which attributes are required. It also runs accessibility checks and a few best-practice checks. It is not the official W3C checker, and the two do not always agree. For full conformance checking, the reference is the W3C Nu Html Checker at validator.w3.org.
Errors are real problems. Examples are an img element with no alt attribute, a p closed while a b inside it is still open, or an old tag such as center. Warnings are softer advice, such as a script with an unneeded type attribute or a button without a type. Each message links to the rule's own page, which explains why it matters and how to fix it. Copy report gives you every message as plain text.
Why fix markup that browsers display anyway? Browsers quietly guess how to repair broken HTML, and their guesses can shift layouts, break scripts or confuse screen readers. A missing alt text, for example, is both a validation error and an accessibility problem. Valid markup also makes structured data and meta tags easier for search engines to read.
The validator code, about 130 kB compressed, loads the first time you click Validate HTML. The limit is 1 MB of HTML. It checks the markup exactly as you give it, so content added later by JavaScript is not included. To show characters such as < and & as text, the HTML Entity Encoder and Decoder turns them into safe entities. The Meta Tag Generator writes valid SEO and social tags for your head section.
Sources
Frequently Asked Questions
Related Tools
HTML Minifier
Minify HTML by removing comments and collapsing whitespace between tags and inside tags to reduce document size.
Developer ToolsHTML Entity Encode and Decode
Convert special characters to HTML entities and decode HTML entities back to readable text.
Developer ToolsMeta Tag Generator
Generate HTML meta tags for SEO, Open Graph, and Twitter Cards with a live preview of search and social results.
Web and SEO Tools