An HTML validator reads the HTML of a page and compares it with the rules of the HTML standard: which elements may sit inside which, which attributes each element takes, and which values are allowed. It lists every problem with its line number. It doesn't render the page, judge the design or tell you whether the content is any good.
The W3C calls its current tool a checker rather than a validator, and that word fits better: it finds mistakes, it doesn't certify a page.
Which validator to use
For any page that starts with <!DOCTYPE html>, which is almost every page built today, use the Nu Html Checker at validator.w3.org/nu. Paste a URL, upload a file or paste the code. Its options let you show the page's heading outline, check error pages such as your 404 page, and send a different User-Agent.
The classic W3C Markup Validation Service at validator.w3.org is built around older document types such as HTML 4.01 and XHTML 1.0. It links to the Nu checker for everything else.
To check many pages, or to check HTML as part of a build, run the same checker yourself. It's called vnu and comes as a Java file, a Docker image, and npm and Homebrew packages. For example:
java -jar vnu.jar --skip-non-html public/
That checks every HTML file in the folder. The Java file needs Java 17 or later. vnu documentation
What a validator flags
Most messages fall into a few groups:
- Missing required attributes, such as an
<img>without analtattribute. - Elements in places they aren't allowed, such as a
<div>inside a<span>, or an<img>in the<head>. - Stray or mis-nested end tags, where the code closes something that isn't open, or closes elements in the wrong order.
- Duplicate
idvalues on one page. - Obsolete elements and attributes, such as
<center>or<font>.
Fix from the top of the list. One mis-nested element can produce a string of later messages that disappear once the first one is fixed.
Does valid HTML matter for SEO?
Mostly no. Google's SEO starter guide says the web in general is not valid HTML, so its systems can rarely rely on the finer rules of the specification. A page full of small validation errors can rank well, and a perfectly valid page can rank nowhere.
There's one important exception: the <head>. Only title, meta, link, script, style, base, noscript and template belong there. When Google meets any other element in the head, it assumes the head has ended and ignores everything after it. Google Search Central
Say a tag manager injects a tracking <img> near the top of the head. Your canonical link, robots meta tag and hreflang links further down may then be ignored by Google. A validator reports the problem on the first run. See meta tags for what usually lives in the head.
Validation also catches problems that affect people using screen readers, such as images without alternative text and duplicate IDs that labels point to. The W3C explains that many validity rules exist for exactly these reasons: accessibility, interoperability, security and predictable behavior in browsers.
Which errors to fix first
- Anything invalid in the
<head>, especially above your canonical, robots and hreflang tags. - Missing
altattributes and duplicate IDs. - Stray and mis-nested tags, because browsers repair them in ways you may not expect, and the page you see can differ from the code you wrote.
- Obsolete elements, when you next touch that template.
You don't need a zero-error report. Treat the rest as housekeeping.
What a validator can't tell you
A validator checks the HTML your server sends. Content that JavaScript adds later isn't in it. To check the page as the browser built it, the Nu checker's About page offers a bookmarklet that sends the current page's DOM to the checker.
Zero errors today doesn't mean zero errors next month. The checker keeps adding new checks, and its makers say it's a checker, not a pass/fail certification. W3C
It also doesn't check whether your links work. That's a job for a link checker. For more on the markup itself, see HTML.