Home › Developer Tools › HTML Validator

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:

Ln 1, Col 1

    Tip: press Ctrl + Enter to validate and click an issue to jump to its line and column in the editor.

    Advertisement
    Advertisement

    How to use the HTML Validator

    1. Paste your HTML into the editor, or click Open file to load an .html file.
    2. Choose the validator: the built-in checker (private and instant) or the W3C Nu HTML Checker (online).
    3. Click Validate HTML or press Ctrl + Enter. With Validate as I type on, the built-in checker updates while you edit.
    4. Click an issue to jump to the exact line and column; the line is highlighted in the editor.
    5. 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

    MessageWhat it meansFix
    Unclosed element divAn 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 spanAn 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 closedTags overlap, e.g. <a><b>…</a></b>.Close inner elements first: <a><b>…</b></a>.
    Element div not allowed as child of element spanBlock (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 ulLists may only contain li items directly.Wrap the content in <li>.
    Duplicate ID introTwo 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 attributeScreen readers and search engines need a text alternative.Describe the image, or use alt="" for decoration.
    The center element is obsoletePresentational HTML from the 1990s that HTML5 removed.Use CSS: text-align:center or margin:0 auto.
    Named character reference was not terminated by a semicolonAn entity such as &copy lacks its ;.Write &copy;, or &amp; 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.

    Related tools

    CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.HTML FormatterBeautify and indent HTML code with a live preview.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.Meta Tag AnalyzerPaste page HTML to audit title, description, canonical, robots, Open Graph and hreflang tags.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.CSS FormatterBeautify CSS with indent controls and optional property sorting.XML FormatterBeautify, validate and minify XML with a collapsible tree view.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JSON MinifierMinify and validate JSON, sort keys and see exactly how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.
    See all 41 Code Formatters & Validators →