HTML Validator
Paste your HTML or open a file to find errors instantly: unclosed and misnested tags, stray end tags, duplicate IDs, obsolete elements, missing alt text and more. Click any issue to jump to its line, or run the same code through the official W3C Nu HTML Checker.
Last updated:
The W3C option sends your HTML to validator.w3.org (the official Nu HTML Checker) for checking. Use the built-in checker for private code.
Tip: press Ctrl + Enter to validate and click an issue to jump to its line and column in the editor.
How to use the HTML Validator
- Paste your HTML into the editor, or click Open file to load an .html file.
- Choose the validator: the built-in checker (private and instant) or the W3C Nu HTML Checker (online).
- Click Validate HTML or press Ctrl + Enter. With Validate as I type on, the built-in checker updates while you edit.
- Click an issue to jump to the exact line and column; the line is highlighted in the editor.
- Fix and recheck until the summary shows no errors, then copy or download the report if you need it.
Common HTML errors and how to fix them
| Message | What it means | Fix |
|---|---|---|
Unclosed element div | An element that needs an end tag was never closed, so everything after it becomes its content. | Add </div> where the element ends; an editor with code folding makes the gap easy to see. |
Stray end tag span | An end tag has no matching open element, often after a typo or a copy-paste. | Remove it or add the missing start tag. |
End tag a seen, but element b was never closed | Tags overlap, e.g. <a><b>…</a></b>. | Close inner elements first: <a><b>…</b></a>. |
Element div not allowed as child of element span | Block (flow) content inside an inline (phrasing) element. | Swap the outer element for a div, or the inner one for a span. |
Element div not allowed as child of element ul | Lists may only contain li items directly. | Wrap the content in <li>. |
Duplicate ID intro | Two elements share an id, which breaks anchors, labels, CSS and scripts. | Make each id unique, or use a class for shared styling. |
An img element must have an alt attribute | Screen readers and search engines need a text alternative. | Describe the image, or use alt="" for decoration. |
The center element is obsolete | Presentational HTML from the 1990s that HTML5 removed. | Use CSS: text-align:center or margin:0 auto. |
| Named character reference was not terminated by a semicolon | An entity such as © lacks its ;. | Write ©, or & for a literal ampersand. |
Errors, warnings and tips
Errors are violations of the HTML standard: browsers will still display the page, but they must guess how to repair it and may build a different document tree than you intended, which can break CSS selectors, JavaScript and screen readers. Warnings point to markup that is valid but probably not what you meant, such as a section without a heading or a form field without a label. Tips are optional best practices, like declaring <meta charset="utf-8"> and a viewport tag.
The minimal valid HTML5 document is short: <!DOCTYPE html>, an <html lang="en"> element, a <head> with <meta charset="utf-8"> and a non-empty <title>, and a <body>. If the input has no doctype, html, head or body tag, it is checked as a fragment and the document-level rules are skipped, so you can validate a snippet or component on its own.
Frequently asked questions
What does an HTML validator check?
It compares your markup with the rules of the HTML Living Standard: whether every element is allowed where it appears, that tags are opened and closed in the right order, that required attributes such as alt on images are present, that IDs are unique and that obsolete elements and attributes are not used. Browsers silently repair invalid HTML, often in different ways, so validation catches problems before they become layout, accessibility or SEO bugs.
What is the difference between the built-in checker and the W3C validator?
The built-in checker runs locally in your browser, so nothing is uploaded and results appear as you type. It covers the most common errors. The W3C option sends your HTML to the official Nu HTML Checker at validator.w3.org, which implements the complete specification, including every attribute value; use it for a final check of public pages.
Why do I get 'No p element in scope but a p end tag seen'?
A paragraph cannot contain block elements. When the parser meets a div, list, table or heading inside a p, it closes the paragraph automatically, so your later </p> has nothing to close. Use a div as the outer element, or end the paragraph before the block.
Do I have to close every tag in HTML5?
No. Void elements such as br, img, input and meta never have end tags, and some elements have optional end tags, including p, li, td, tr, option, html, head and body. Every other element, such as div, span, a, section and ul, must be closed explicitly, and elements must be closed in the reverse order they were opened.
Is <br/> or <img ... /> invalid?
No. A trailing slash on a void element is allowed and simply ignored, so the validator only shows a tip. On non-void elements, such as <div/>, the slash is ignored too, which means the element stays open and usually swallows the content after it, so that is reported as an error.
Does valid HTML improve SEO?
Search engines can read most invalid HTML, and Google has said validation is not a direct ranking factor. Errors still matter indirectly: a missing title, an unclosed tag that hides content, missing alt text or broken heading structure can affect how a page is indexed, displayed and used by people with assistive technology.
Can it validate PHP, React or template files?
Only the HTML they output. Server-side code such as <?php ... ?> or template tags like {{ ... }} is not HTML, so run the page and validate the generated source (View page source in your browser) instead of the template.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.