Real-Time · W3C Standards · Zero Setup

Online HTML Validator & Code Checker

Spot and fix HTML errors before they break your page.

Real-time Error detection
W3C Standards checked
0 Setup required
Free Always & forever
Standards Check

Check Your HTML Against Web Standards

A validator reads your markup the way a browser's parser does, then measures it against the HTML specification — flagging anything malformed, ambiguous, or quietly corrected behind your back.

When a browser meets broken HTML it almost never shows an error. Instead it guesses — closing tags for you, relocating stray content, and building a document tree that may not match what you intended. That forgiveness is convenient right up until two browsers guess differently and your layout breaks in one of them. Validation removes the guesswork: it points at the exact line where your markup leaves the standard, so you fix the cause instead of chasing the symptom.

Checking happens across several layers at once, from raw characters up to document semantics. Write your markup in the HTML code editor, then run it through the points below.

Syntax & Well-Formedness

Every opened tag is closed, angle brackets and quotes are balanced, and attribute values are properly delimited. Malformed syntax is the single most common reason a page renders nothing like its code.

Element Nesting Rules

The specification defines which elements may contain which. An <li> belongs inside a <ul> or <ol>; a block element cannot sit inside a <p>. The checker catches nesting the parser would otherwise silently rearrange.

Required Attributes

Some attributes are mandatory: <img> needs alt, the root <html> needs lang, and form controls need names. Omit them and the page looks valid but loses accessibility, function, or both.

Document Structure

A conforming page needs a doctype, one root <html>, a <head> with a character set, and a <body>. Skip the doctype and browsers drop into quirks mode with legacy box behaviour.

Obsolete Elements

Elements such as <center>, <font> and <marquee>, and attributes like bgcolor, were dropped from the standard years ago. They may still render, but they flag as errors and belong in CSS now.

Duplicate IDs

An id must be unique on the page. Duplicates break in-page anchors, label associations, and any script or stylesheet that targets that id — a subtle bug the validator surfaces at once.

Errors & Fixes

Common HTML Errors and How to Fix Them

Most validation failures come from the same short list. Here are the ones you will meet most often, why each one matters, and the exact fix.

Unclosed elements

A tag you open but never close stays open, swallowing everything after it. Give it a matching end tag — <p>Hello</p>, not a bare <p>Hello. Void elements such as <img> and <br> need no closing tag at all.

Overlapping tags

Elements must nest, never cross. <b><i>text</b></i> is invalid because the bold closes before its child. Close the inner element first: <b><i>text</i></b>.

Missing alt text

<img src="logo.png"> with no alt fails validation and hides the image from screen readers. Describe it — alt="Company logo" — or use an empty alt="" for purely decorative images.

Duplicate id values

An id must be unique. Two elements sharing id="main" break in-page links, label associations and scripts. Rename one, or switch to a class when you genuinely need a shared hook.

Unescaped characters

A literal & or < in text confuses the parser. Write them as entities — &amp; and &lt; — so Tom & Jerry appears as Tom &amp; Jerry in the source.

Missing doctype

Leave out <!DOCTYPE html> and the browser renders in quirks mode, reviving legacy box-model behaviour. Make it the very first line of every document, above <html>.

Unquoted attribute values

<input type=text value=hi there> breaks at the space — there is read as a stray attribute. Quote the values: <input type="text" value="hi there">.

Loose text in a list

<ul> and <ol> may only hold <li> children. Wrap every entry — <li>Item</li> — instead of dropping text straight into the list.

Wrong vs Right

The HTML Error Catalog: 14 Mistakes and Their Fixes

Every entry below is a real validation failure paired with the exact correction. Read the invalid version, then the valid one — the fix is almost always smaller than the bug.

1. Unclosed element

An element you open but never close keeps absorbing the content after it until the parser guesses where it should end.

Invalid
<p>First paragraph.
<p>Second paragraph.
Valid
<p>First paragraph.</p>
<p>Second paragraph.</p>

2. Improperly nested tags

Elements must nest cleanly: an inner element has to close before the element that contains it does.

Invalid
<b><i>Bold italic</b></i>
Valid
<b><i>Bold italic</i></b>

3. Image with no alt attribute

Every <img> needs an alt attribute — descriptive for meaningful images, empty for decorative ones.

Invalid
<img src="team.jpg">
Valid
<img src="team.jpg"
     alt="Our team on launch day">

4. Duplicate id value

An id must be unique on the page; repeats break in-page anchors, label associations, and any script or stylesheet that targets that id.

Invalid
<div id="card"></div>
<div id="card"></div>
Valid
<div id="card-1"></div>
<div id="card-2"></div>

5. Unescaped special characters

A bare &, < or > in text can be read as markup. Write them as HTML entities.

Invalid
<p>Fish & chips for < $5</p>
Valid
<p>Fish &amp; chips for &lt; $5</p>

6. Missing doctype

With no doctype the browser falls back to quirks mode and its legacy box model. Make it the very first line of the document.

Invalid
<html>
  <head>…</head>
Valid
<!DOCTYPE html>
<html lang="en">
  <head>…</head>

7. Unquoted attribute containing a space

An unquoted value ends at the first space, so everything after it is misread as extra attributes.

Invalid
<input type=text value=Jane Doe>
Valid
<input type="text" value="Jane Doe">

8. Block element inside a paragraph

A <p> may hold only inline content; a block element inside it forces the paragraph to close early, scrambling the tree.

Invalid
<p>Summary <div>details</div></p>
Valid
<p>Summary</p>
<div>details</div>

9. Missing lang on the root element

The lang attribute tells browsers, screen readers and translation tools which language the page is written in.

Invalid
<html>
Valid
<html lang="en">

10. No character encoding declared

Declare UTF-8 as the first thing inside <head>, or accented and non-Latin characters can render as garbled symbols.

Invalid
<head>
  <title>Café menu</title>
</head>
Valid
<head>
  <meta charset="UTF-8">
  <title>Café menu</title>
</head>

11. Label not associated with its input

A <label> must reference its control with matching for and id (or wrap it), or clicking the label does nothing and screen readers lose the field name.

Invalid
<label>Email</label>
<input type="email">
Valid
<label for="email">Email</label>
<input type="email" id="email">

12. Skipped heading level

Headings form the page outline. Jumping from <h1> straight to <h4> leaves gaps that confuse readers and crawlers reading that outline.

Invalid
<h1>Guide</h1>
<h4>Step one</h4>
Valid
<h1>Guide</h1>
<h2>Step one</h2>

13. Loose text inside a list

<ul> and <ol> may contain only <li> children — wrap every entry rather than dropping text straight in.

Invalid
<ul>
  Apples
  Pears
</ul>
Valid
<ul>
  <li>Apples</li>
  <li>Pears</li>
</ul>

14. Obsolete elements and attributes

Presentational tags such as <center> and attributes like bgcolor were dropped from HTML5. Move the styling into CSS.

Invalid
<center>
  <p bgcolor="yellow">Sale</p>
</center>
Valid
<p style="text-align:center;
          background:yellow">Sale</p>
Real-World Impact

How Invalid HTML Hurts SEO, Accessibility & Rendering

The same mistake often bites in three places at once. This table maps common validation failures to their cost for search visibility, assistive technology, and how the page draws.

Mistake SEO impact Accessibility impact Rendering impact
Malformed <head> Title and meta description can be dropped from results Page language and context become unclear Body content can slip into the head and never render
Missing alt text Images can't be understood or ranked in image search Screen readers announce nothing, or read the filename Broken images show no descriptive fallback
Duplicate id In-page anchor links may resolve to the wrong spot Label-to-input associations break Scripts and styles target the wrong element
Skipped heading levels Weakens the topical outline crawlers read Heading-by-heading navigation jumps or stalls Minimal — a hidden problem with no visible symptom
Unclosed <div> Content can be misattributed to the wrong section Focus and reading order jump unexpectedly Later sections nest inside the wrong container
Invalid JSON-LD Rich results silently never appear Minimal — not surfaced to assistive tech Minimal — no visible change
Missing lang attribute Wrong-language targeting and hreflang confusion Screen reader uses the wrong pronunciation rules Minimal — no visible change
Obsolete presentational tags Bulkier, noisier markup that is harder to crawl Meaning is lost — no semantics for assistive tech Styling drifts between browser engines
Why It Matters

Why Valid HTML Matters for SEO & Accessibility

Clean markup is not pedantry. Broken HTML carries concrete costs — for how you rank, who can use your page, and how consistently it renders.

Crawlers parse exactly what you ship. A malformed <head> can hide your title and description from results, and broken structure can bury the content beneath it.
Structured data fails as a unit. One stray character in a JSON-LD or microdata block can invalidate the whole snippet, so your rich results quietly never appear.
Screen readers depend on a correct tree. Missing alt text, unlabeled inputs and skipped heading levels leave assistive technology — and its users — guessing.
Heading order is your page outline. Jumping from <h1> straight to <h4> confuses users and the crawlers that read the outline to understand the page.
Cross-browser consistency. When markup is ambiguous, every engine repairs it its own way; valid HTML renders the same in Chrome, Firefox and Safari.
Fewer layout mysteries. A single unclosed <div> can pull your footer inside the article — valid structure removes an entire category of CSS bug.

Reach for semantic markup from the start — build and test it in the HTML5 editor — and most of these problems never appear. Once the validator comes back clean, download your project as ready-to-deploy files.

Before You Ship

The Pre-Publish Validation Checklist

Run through this once before every deploy. It catches the errors a validator flags and the standards issues it can't, so the page you publish is the page you meant to.

Clear on every point? Assemble and re-check the page in the HTML code editor, then download the validated project as deploy-ready files.

FAQ

HTML Validation — FAQ

It checks two things: whether your markup is well-formed (tags opened and closed, correctly nested, attributes quoted) and whether it conforms to the HTML specification (only allowed elements and attributes, required attributes present, a valid document structure). Together those catch the errors browsers would otherwise silently paper over.
Unclosed or overlapping tags, missing alt attributes on images, duplicate id values, unescaped & and < characters, a missing doctype, unquoted attribute values, and text placed directly inside a list instead of an <li>. Almost every page that fails validation fails on one of these.
Not directly for small mistakes — Google tolerates a lot of messy HTML. But invalid markup can break structured data, hide your title or meta description, cause content to be parsed in the wrong order, or render inconsistently, and each of those can hurt how your page is indexed and shown. Valid HTML removes that risk.
An unclosed tag means you opened an element and never closed it — add the matching closing tag, or self-close a void element correctly. A stray end tag is the opposite: a closing tag with no matching opener, usually left behind after deleting code. Remove it, then re-check to confirm the tree balances.
It is the foundation. Screen readers and other assistive technology rely on a correct document tree, real labels, alt text and a logical heading order. Valid, semantic markup gives them accurate information; invalid markup forces them to guess, which is where accessibility breaks down.
Yes. You can paste a fragment — a single component or section — and check it in isolation. Bear in mind that some checks, like a missing doctype or a duplicate id elsewhere on the page, only apply to a full document, so validating the complete page as well is worth doing before you ship.
Usually, yes — browsers are deliberately forgiving and will repair broken markup on the fly so something appears. The catch is that each engine repairs it its own way, so an invalid page can look fine in one browser and wrong in another. Validation is how you stop relying on that repair and get the same result everywhere.
An error is a genuine violation of the specification — an unclosed tag, a duplicate id, a missing required attribute — and should always be fixed. A warning is advisory: something technically allowed but risky or discouraged, like an empty heading or a questionable practice. Clear the errors first; then work through the warnings that apply to your page.
An editor's inline checker flags syntax as you type — a missing bracket, a mistyped tag — line by line. A validator judges the whole finished document against the standard: doctype and structure, ids that must be unique across the page, required attributes, and element nesting rules. The two are complementary — write with inline hints, then validate the complete page before you publish.
Related Tools

Explore the Full HCODX Suite

HTML Editor

Full-featured HTML editor with live preview and Monaco engine.

Split-Screen Preview

Code on the left, live rendered output on the right.

Live HTML Editor

Real-time preview that updates with every keystroke.

HTML CSS JS Editor

Unified editor for all three front-end languages.

Multi-File Editor

Manage complex projects with multiple files and folders.

VS Code Online Free

Monaco-powered editor with VS Code shortcuts and IntelliSense.

Validate Your HTML Now

Catch syntax errors, unclosed tags and compliance issues in real-time — before they reach production.

Instant HTML Runner & Viewer with Live Preview

Want to run your HTML, CSS, and JavaScript code instantly and see the result live? Try our free HTML Runner Online — a lightweight browser-based code runner and viewer with real-time live preview. No download or signup required.

Open HTML Runner Online