Skip to content

HTML Validator

✨ Checks as you type 0 lines · 0 B

Results

    Paste HTML or click Sample

    Problems will show up here, line by line

    HTML Validator – Free Online Tool

    What is an HTML Validator?

    An HTML validator reads your markup and points out the mistakes: a tag you forgot to close, an id you used twice, an image with no alt text. You paste your code on the left, and the list of problems shows up on the right, with the exact line and column for each one.

    “But my page looks fine!” Sure, because browsers are very forgiving. When your HTML is broken, the browser quietly guesses what you meant and keeps going. The guess is often right, until it isn’t. A missing </div> that did nothing today swallows your footer tomorrow. Clean HTML also matters beyond the layout: screen readers depend on it (alt text, proper links and buttons), and search engines read your <title>, headings and structure to understand the page.

    Everything runs right here in your browser. Your code isn’t uploaded anywhere.

    How to Use It – Step by Step

    Five quick steps. Each one shows a common mistake and how to fix it. Paste the “before” code into the validator and see what it says.

    Step 1 Paste or Open Your HTML

    Get some HTML into the editor on the left. Pick whichever is easiest:

    • Paste it: copy HTML from your code editor, a CMS, an email template or anywhere else.
    • Open a file: click the upload button, or just drag your .html file onto the editor.
    • Click Sample: loads a small page with a few mistakes hidden in it. Can you fix them all?

    There’s no Check button. The results update a moment after you stop typing, so you can fix something and watch the problem disappear.

    💡 A snippet like <p>Hi</p> is checked as a piece of a page. Add <!DOCTYPE html> or an <html> tag and it’s checked as a full page, with extra checks for the doctype, the <title> and the language.

    Step 2 Read the Results and Jump to Each Problem

    Every problem shows a red error or amber warning badge, where it is (line and column), what’s wrong in plain English, and the name of the rule. Click a problem and the validator selects that line in the editor, so you don’t have to hunt for it. Start at the top: one unclosed tag can cause the errors that come after it.

    Example: a tag that’s never closed

    ❌ Before:

    <div class="card">
      <h2>Pricing</h2>
      <p>Only <strong>$5 a month</p>
    </div>

    ✅ After:

    <div class="card">
      <h2>Pricing</h2>
      <p>Only <strong>$5</strong> a month</p>
    </div>

    The validator says: “<strong> is opened but never closed. Add </strong> before </p>.” Without the fix, the browser makes everything up to the end of the paragraph bold, which isn’t what you meant.

    Step 3 Fix the Errors First

    Errors change how the browser builds your page, so they come first. Two you’ll see a lot are duplicate ids and duplicate attributes. An id must be unique on the page, otherwise getElementById, CSS and <label for> grab the wrong element. And when an attribute appears twice on one tag, the browser only keeps the first one.

    Example: duplicate id and duplicate class

    ❌ Before:

    <button id="save" class="btn">Save</button>
    <button id="save" class="btn" class="primary">
      Save all
    </button>

    ✅ After:

    <button id="save" class="btn">Save</button>
    <button id="save-all" class="btn primary">
      Save all
    </button>

    💡 Need more than one class? Put them in a single attribute, separated by spaces: class="btn primary".

    Step 4 Don’t Skip the Warnings

    Warnings won’t break your page, but they’re usually quick wins for accessibility. Use the Errors / Warnings filter to look at them on their own. The classics: an image without alt text (screen readers can’t describe it), and an <a> without an href, which isn’t a real link, so keyboard users can’t reach it.

    Example: missing alt text and a fake link

    ❌ Before:

    <img src="team.jpg">
    <a onclick="openMenu()">Menu</a>

    ✅ After:

    <img src="team.jpg" alt="Our team at the summer meetup">
    <button type="button" onclick="openMenu()">Menu</button>

    💡 Purely decorative image? Use an empty alt="". Screen readers will skip it, and the warning goes away.

    Step 5 Check the Full Page

    When you paste a whole page, you also get the page-level checks: the <!DOCTYPE html> line (without it, browsers fall back to an old “quirks mode”), a <title> for the browser tab and search results, a lang attribute for screen readers, and scripts in <head> that block the page from showing.

    Example: a page missing the basics

    ❌ Before:

    <html>
    <head>
      <script src="app.js"></script>
    </head>
    <body>
      <h1>Hello</h1>
    </body>
    </html>

    ✅ After:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Hello</title>
      <script src="app.js" defer></script>
    </head>
    <body>
      <h1>Hello</h1>
    </body>
    </html>

    All green? Nice work. Here’s what to do next:

    • Tidy it up: run it through the HTML Formatter for clean, consistent indentation.
    • See it: paste it into the HTML Viewer to check how it looks on phone, tablet and desktop.
    • Keep building: add CSS and JavaScript in the HTML Editor with a live preview.

    Need a full check against the HTML specification, for example before a big launch? Run your page through the W3C Markup Validation Service too.

    Frequently Asked Questions

    Is this the same as the W3C validator?

    No, and it’s good to know the difference. This tool is a fast check that runs in your browser and catches the common problems that actually bite: unclosed tags, duplicate ids, missing alt text, a missing <title> and so on. It updates as you type. The W3C Markup Validation Service (validator.w3.org) checks your page against the full HTML specification. Use this one while you work, and run the W3C validator before a big launch if you need full spec conformance.

    What’s the difference between errors and warnings?

    Errors are mistakes that change how the browser builds your page, like a tag that’s never closed or an id used twice. Fix those first. Warnings are good practice: the page still works, but something like missing alt text hurts accessibility, or a script in <head> slows loading down. Use the All / Errors / Warnings filter to focus on one kind at a time.

    Is my HTML uploaded anywhere?

    No. The checks run right here in your browser, so your code never leaves your computer. You can even disconnect from the internet after the page loads and it keeps working.

    How do I fix “never closed” errors?

    Click the issue to jump to the tag that was opened, then find where that element should end and add the closing tag there, like </div>. If the code is hard to follow, run it through the HTML Formatter first. With proper indentation, a missing closing tag is much easier to spot. Fix the first one and re-check, because one missing tag often causes the errors after it.

    Does it check my CSS and JavaScript?

    No. It checks the HTML only. Anything inside <style> and <script> tags is skipped, so a < in your JavaScript won’t be reported as a problem. To check CSS or JavaScript, use a linter made for them, like Stylelint or ESLint.

    Why doesn’t it complain about a missing doctype or <title> in my snippet?

    On purpose. If your code has no <!DOCTYPE html> and no <html> tag, it’s treated as a snippet, like a piece of a page, and the page-level checks are skipped. As soon as you add either one, it’s checked as a full page, and the doctype, <title>, lang and head script checks switch on.

    My page looks fine in the browser. Why does it show errors?

    Because browsers are very forgiving. They quietly guess what you meant and fix the markup for you. The guess is often right, but not always, and different browsers can guess differently. A tag that’s never closed might look fine today and break the layout when you add the next section. Fixing the errors means the browser builds exactly what you wrote.