HTML Validator

Clean, standards-compliant HTML is the foundation of fast page rendering, predictable browser styling, search engine crawlability, and assistive accessibility. When markup contains unclosed tags, mismatched nesting, or duplicate IDs, modern web browsers attempt silent error correction, frequently causing erratic layout shifts, broken JavaScript listeners, and inaccessible screen reader trees. This free, client-side HTML Validator audits your markup in real time against modern W3C HTML5 and WCAG 2.2 standards. It instantly highlights syntax errors, unclosed containers, missing image alt attributes, broken heading structures, and deprecated tags with exact line and column numbers—all computed strictly in your browser with zero server uploads.

Free developer tool · 100% client-side validation

Validate your HTML markup

Audits HTML5 syntax, tag nesting, WCAG 2.2 accessibility, SEO tags, and deprecated elements in real time with line-by-line diagnostics.

  • Syntax & Tag Pairing
  • WCAG 2.2 Accessibility
  • Heading Hierarchy & SEO
  • Zero Server Uploads

HTML markup

Real-time syntax & DOM inspection
Chars: 0 Lines: 0

Validation score

Paste HTML code on the left to see your validation health score, errors, and fixes.

0 out of 100
— Valid HTML

Audited against W3C HTML5 standards.

  • Errors
    0
  • Warnings
    0
  • Notices
    0
  • Tags
    0
Syntax & Nesting Conformance 100%
WCAG Accessibility Integrity 100%
SEO & Document Structure 100%

Diagnostics & issues

No diagnostics to display. Enter HTML markup above to begin validation.

Heading hierarchy & document outline

Enter HTML markup to inspect your document's heading structure.

Why HTML Validation Matters for Modern Web Development

HyperText Markup Language (HTML) is the foundational structural backbone of every page and web application rendered by modern browsers. Over decades of browser development, rendering engines such as Google Chrome's Blink, Apple Safari's WebKit, and Mozilla Firefox's Gecko have engineered extraordinarily resilient error recovery algorithms. When an engineer writes an unclosed <div>, forgets to close a <p> before nesting a block element, or leaves an attribute quote unclosed, the browser's loose parsing algorithm steps in to repair the Document Object Model (DOM) tree silently on the fly.

While lenient error correction prevents pages from crashing outright, relying on browser auto-repair is a dangerous practice in production engineering. Different rendering engines handle malformed HTML in divergent ways. An unclosed container tag that appears innocuous in desktop Google Chrome can cause complete layout breakage in Safari on iOS, collapse flexbox child calculations, or swallow subsequent page sections. Furthermore, when the DOM is malformed, client-side JavaScript libraries (such as React, Vue, or vanilla query selectors) encounter unpredictable node hierarchies, breaking click event delegations and component lifecycles.

Beyond visual layout consistency, valid HTML directly governs three critical pillars of modern web success: search engine crawlability, assistive technology accessibility (a11y), and web performance. When automated bots like Googlebot or Bingbot traverse a page with corrupted DOM nesting, their scrapers can misunderstand heading hierarchies, fail to index critical paragraphs, or misattribute links. Similarly, screen readers rely on well-formed parent-child DOM relationships to build an Accessible Name and Description Computation tree. Validating HTML ensures that your digital experience is resilient, accessible, and easily discoverable across every device.

The Most Common HTML Conformance & Syntax Errors

Modern HTML5 has simplified document authoring, yet several categories of errors continue to plague both legacy codebases and modern web applications. Understanding why these errors occur and how browsers treat them is essential for writing professional-grade markup:

1. Unclosed and Mismatched Container Elements

In HTML, elements are categorized into container elements (which require both an opening and a closing tag) and void elements (which cannot contain child nodes or closing tags). Forgetting to close container elements such as <div>, <section>, <span>, or <ul> leaves the element open on the parser stack. As subsequent elements are encountered, they are mistakenly treated as child descendants rather than sibling elements. When closing tags are interleaved in the wrong order—such as opening <strong><em> but closing </strong></em>—the browser must perform synthetic tag closing and reopening operations, degrading parsing speed and bloating memory usage.

2. The Dangerous HTML5 Self-Closing Slash Trap

One of the most widespread misconceptions among frontend engineers transitioning from XML or XHTML to HTML5 is the behavior of the self-closing slash (/>). In XML and JSX (React), writing <div /> or <span /> immediately closes the element. However, in standard HTML5, the trailing slash on non-void elements is completely ignored by the parser. Writing <div class="card" /> does not close the tag; it leaves the <div> wide open, causing every subsequent element on the page to be trapped inside it until the parser finds an explicit closing </div> or reaches end-of-file. In HTML5, only void elements (such as <img>, <br>, <input>, <meta>, and <hr>) can omit an end tag.

3. Void Elements with Prohibited End Tags

Conversely, attempting to close void elements with an end tag—such as writing <img src="pic.jpg"></img> or <br></br>—is a strict violation of the HTML specification. Void elements are forbidden from having children or end tags. When a browser encounters an explicit </img>, it treats the end tag as a stray or illegal token, logging errors in linting pipelines and occasionally generating ghost text nodes in legacy email clients.

4. Duplicate Element IDs

The id attribute specifies a unique identifier within the document tree. The HTML5 specification dictates that an ID must be unique across the entire document. When duplicate IDs exist, fundamental browser APIs fail. Specifically, document.getElementById() returns only the first matching element, leaving subsequent elements unreachable via ID lookup. Furthermore, duplicate IDs severely break accessibility: when an <input> references a <label for="user-email"> or an aria-labelledby="section-title" attribute, screen readers cannot determine which element is the intended target, leaving forms and dialogs inaccessible to visually impaired users.

5. Nesting Block Elements Inside Paragraphs

Under the HTML parsing algorithm, a <p> element is strictly phrased content. If an author nests a block element—such as a <div>, <table>, <ul>, or another <p>—inside an open paragraph, the browser automatically closes the <p> immediately before the block element begins. For example, writing <p>Text <div>Box</div></p> is silently transformed by the browser into <p>Text</p><div>Box</div><p></p>. This unexpected DOM splitting breaks CSS descendant selectors (such as p > div) and introduces phantom margins.

Accessibility (WCAG 2.2) and SEO Standards

HTML validation is inextricably linked with web accessibility and search engine optimization. A page that passes raw tag balancing can still fail critical conformance criteria if semantic attributes and document metadata are neglected. This tool audits the following accessibility and SEO standards:

  • Image Alternative Text (WCAG 1.1.1): Every <img> element must include an alt attribute. For informative images, the alt text must succinctly convey the purpose and content of the graphic. For purely decorative images that provide no content value, authors must specify an empty string (alt=""), signalling to assistive screen readers to bypass the element cleanly. Omission of the alt attribute forces screen readers to read aloud the raw image file URL, frustrating users.
  • Accessible Form Controls (WCAG 1.3.1 & 4.1.2): All interactive form elements (including <input>, <select>, and <textarea>, excluding hidden fields) must have a discernible, programmatically determined name. This can be achieved by associating the input's id with a matching <label for="id">, wrapping the input directly inside a <label> container, or declaring an explicit aria-label or aria-labelledby attribute.
  • Logical Heading Hierarchy: Heading tags (<h1> through <h6>) define the semantic outline of a document. Pages should possess a single primary <h1> that communicates the core topic of the page to both users and search crawlers. Furthermore, heading levels should not skip steps (for example, stepping directly from an <h1> to an <h3> without an intermediate <h2>), as screen reader users frequently navigate pages by jumping between heading levels.
  • Safe External Target Links: Any hyperlink utilizing target="_blank" to open external websites must specify rel="noopener" or rel="noreferrer". Without these attributes, the opened page gains access to the originating window's window.opener object, introducing severe reverse tabnabbing and phishing vulnerabilities in legacy and embedded webviews.
  • Document Metadata & Viewport: Full HTML documents require a clean <!DOCTYPE html> declaration to prevent browsers from reverting to legacy Quirks Mode, along with a declared language code (such as <html lang="en">) to allow screen readers to adopt proper pronunciation rules. Responsive viewport tags (<meta name="viewport" content="width=device-width, initial-scale=1.0">) ensure that mobile browsers scale content correctly without horizontal viewport overflow.

Obsolete HTML5 Tags & Their Modern CSS Replacements

The HTML5 specification formally declared numerous presentational tags and formatting attributes obsolete, encouraging a strict separation between semantic document structure (HTML) and visual presentation (CSS). Using deprecated tags adds unnecessary bloat, conflicts with modern responsive design systems, and often fails modern accessibility audits. Below is an authoritative reference of obsolete HTML tags and attributes alongside their modern, performant CSS alternatives:

Deprecated Element / Attribute Historical Purpose Modern Standards-Compliant Replacement
<center> Center-aligns text or elements Use CSS text-align: center; for inline content, or display: flex; justify-content: center; / margin: 0 auto; for block containers.
<font> (with color, size, face) Inline typography styling Use semantic elements combined with CSS font-family, font-size, and color properties.
<marquee> Horizontally scrolling text ticker Obsolete and severe accessibility hazard (WCAG 2.2.2). Replace with pauseable CSS keyframe animations or accessible carousel patterns.
<blink> Blinking text effect Obsolete. Flashing text can trigger seizures (WCAG 2.3.1). If pulsing emphasis is required, use subtle CSS opacity transitions.
<strike> Strikethrough text line Use <del> to represent removed/deleted content, or <s> for content that is no longer accurate, styled via CSS text-decoration: line-through;.
<tt> / <big> Teletype monospace / enlarged font Use semantic <code>, <kbd>, or <samp> for code, and CSS font-size for enlarged text.
<frameset> / <frame> Multi-pane browser frames Obsolete. Use responsive CSS Grid and Flexbox layouts, or isolated <iframe> elements with modern sandbox permissions if external embedding is required.
align="..." / valign="..." Table/div alignment Use CSS text-align, vertical-align, or Flexbox / CSS Grid alignment properties (align-items, justify-content).
bgcolor="..." Table/body background color Use CSS background-color: #...; in your stylesheet.
cellpadding="..." / cellspacing="..." Table cell spacing Use CSS padding on <td> and <th> cells, and border-spacing or border-collapse: collapse; on the <table>.

How This In-Browser Validator Works

Most simple online HTML checkers rely on sending your code across the internet to an external server or third-party API. In contrast, this validator runs 100% locally in your client's web browser, ensuring complete privacy, instant feedback with zero network latency, and confidentiality for sensitive intranet templates, email drafts, or staging code.

To deliver deep, accurate validation, the tool operates a dual-inspection engine:

  1. Lexical Source-Stream Tokenizer: Because standard browser DOM parsers automatically repair unclosed tags and invalid nesting behind the scenes, a purely DOM-based inspector cannot detect missing closing tags or mismatched tag hierarchies. Our validator features a custom character-by-character lexical scanner that parses the raw input string. It maintains a strict Last-In-First-Out (LIFO) tag stack, detects illegal void element closures, validates attribute quotation boundaries, flags unescaped angle brackets, and maps every finding to its precise source line and column number.
  2. Semantic & Conformance Inspector: Once lexical tokens are collected, the engine evaluates global document structure, verifying doctype declaration, character encoding, responsive viewport meta tags, WCAG accessibility contracts (such as image alt attributes and input label associations), and heading hierarchy sequencing.
  3. Diagnostic Scoring Algorithm: Based on the severity and frequency of discovered issues, the tool computes a transparent Validation Health Score (from 0 to 100), deducting weighted penalties for critical syntax errors (which break DOM construction), moderate warnings (which degrade accessibility or rely on deprecated tags), and minor notices (such as skipped heading levels or placeholder links).

Comparing HTML Validation Tools

Different validation workflows serve different stages of the development lifecycle. The table below compares this client-side validator with the official W3C Nu HTML Checker and native browser developer tools:

Feature / Capability This Client-Side HTML Validator W3C Nu HTML Checker Browser DevTools (Elements Tab)
Data Privacy & Local Execution 100% client-side; zero network requests; safe for private copy and credentials. Requires sending full HTML payload to W3C remote servers (unless self-hosted). 100% client-side inside the local browser instance.
Detects Unclosed / Mismatched Tags Yes; lexical stream parser flags unclosed and interleaved tags with line numbers. Yes; full XML/HTML5 parser detects unclosed elements. No; DevTools automatically repairs and closes tags silently, hiding authoring errors.
Snippet & Component Validation Yes; dedicated "Snippet Mode" allows checking isolated widgets, cards, and email blocks without requiring DOCTYPE or <html> boilerplate. Requires complete standalone document with DOCTYPE, title, and html tags, or flags dozens of boilerplate errors. Inspects only whatever is currently mounted in the active browser page.
WCAG Accessibility Auditing Yes; checks missing image alt text, form label associations, and duplicate IDs. Basic conformance checks only; does not provide dedicated a11y health scoring. Requires running additional Lighthouse or axe-core extension audits.
Instant As-You-Type Feedback Yes; debounced real-time analysis recalculates as you type. No; requires manual form submission and full page reload per check. Live DOM inspection, but does not provide validation scores or fix recommendations.

Frequently Asked Questions (FAQ)

Does invalid HTML directly hurt my Google search rankings?

Google's official webmaster documentation confirms that Googlebot can parse and index pages with minor HTML errors because its rendering engine employs loose error recovery. However, invalid HTML can indirectly devastate your SEO performance. If unclosed tags cause content to be clipped, if meta tags are misplaced outside of the <head> section, or if duplicate IDs confuse Googlebot's understanding of structured data and canonical links, search crawlers may fail to index your key content. Moreover, HTML syntax errors frequently cause significant layout shifts (CLS) and slow down DOM parsing (INP), directly degrading your Core Web Vitals scores.

Why does my web page look completely normal in Chrome if the validator shows errors?

Modern desktop browsers are engineered with aggressive fault-tolerant parsing algorithms designed to display whatever content is available, even if the underlying code is deeply corrupted. For example, if you leave a <div> unclosed, Chrome will automatically insert a synthetic closing tag before the closing </body> tag. While this prevents a blank screen on your specific device, other browsers, mobile devices, search engine crawlers, email clients, and assistive screen readers may interpret the broken DOM hierarchy differently, leading to inconsistent styling, unresponsive touch targets, or missing screen reader announcements.

What is the difference between an HTML void element and an XML self-closing tag?

In HTML5, void elements are predefined elements that cannot have any child content or end tags. The official HTML5 void elements are: area, base, br, col, embed, hr, img, input, link, meta, param, source, track, and wbr. In HTML5 syntax, writing <img src="pic.jpg"> and <img src="pic.jpg" /> are functionally identical; the trailing slash is purely syntactic sugar. However, for non-void elements (like <div> or <span>), the trailing slash has no effect in HTML5. Writing <div /> does not self-close the tag; it leaves the tag open, requiring an explicit </div> closing tag.

Why are duplicate element IDs illegal if CSS classes can be repeated?

In the HTML and CSS specifications, classes (the class attribute) are designed as non-unique classification tokens, allowing multiple elements to share identical styling rules. Conversely, the id attribute is strictly defined as a unique document-wide identifier. Multiple browser specifications depend on this uniqueness: URL fragment hash navigations (example.com#section-2), JavaScript DOM lookups (document.getElementById), and accessibility relationships (such as <label for="id"> and aria-describedby="id") assume that an ID points to exactly one element. Duplicate IDs cause JavaScript errors and prevent screen readers from identifying form controls.

Is my HTML code sent to a remote server or logged when I use this tool?

No. This tool operates 100% locally inside your web browser's JavaScript engine. No code, snippets, filenames, or markup data are ever transmitted across the network, uploaded to external servers, or stored in cookies or local storage. You can safely validate proprietary web components, intranet templates, and staging code without security or compliance concerns.

Can I validate partial HTML snippets, such as email templates or CMS embeds?

Yes. By default, the validator runs in "Full HTML Document" mode, checking for global document requirements such as <!DOCTYPE html>, <html lang>, <head>, and <title>. If you are developing an isolated component, a blog post embed, or an email newsletter block, switch the "Mode" dropdown at the top of the input panel to "HTML Snippet / Embed". In Snippet Mode, boilerplate document checks are suspended while tag closure, nesting, duplicate IDs, accessibility, and modern standards are still strictly enforced.

How should I resolve heading level skipped warnings?

Heading level skipped warnings occur when a lower-tier heading directly follows a higher-tier heading without the natural intermediate step (for example, placing an <h3> directly inside an <h1> section without an <h2>). While visual designers sometimes choose heading tags based on default font sizes, semantic HTML dictates that heading tags represent document hierarchy, not visual appearance. To resolve this warning, maintain sequential numbering (<h1> → <h2> → <h3>) and use CSS utility classes or styles to adjust the visual font size of the heading as desired.