What does “valid” mean — and why bother?
HTML has rules: tags must be closed, nested correctly, and spelled right. Validating means running your page through a tool that checks it against those official rules and reports anything wrong. Browsers guess at broken code, so a page can look fine and still be quietly buggy.
Catch broken markup before it causes weird layout glitches across browsers.
Many validator errors (missing alt, labels) are also accessibility problems.
Search engines and link previews rely on clean, well-formed markup.
The validator points to the exact line, so debugging takes minutes, not hours.
The two official validators
They're free, made by the W3C (the people who write the web standards), and need no account.
HTML Validator
Checks your HTML structure — tags, nesting, attributes, required elements.
validator.w3.orgCSS Validator
Checks your CSS for invalid properties, values, and typos.
jigsaw.w3.org/css-validatorThree ways to feed it your page
However your page lives, there's a tab for it:
Paste a live web address (e.g. your GitHub Pages link). Best once it's published.
Upload an .html file straight from your computer.
Paste your code into a box. Perfect while you're still building locally.
Reading the results
The validator returns a list. Each item is an error (must fix — breaks the rules), a warning (should look at — risky but allowed), or info. Every line tells you where and what. Press “Re-check” below to see what fixing them looks like.
</p> seen, but there were open elements.img element must have an alt attribute.main.lang attribute to the html element.The five most common errors — and the fix
1. Unclosed tag
<p>Welcome to my site <p>Second paragraph</p>
<p>Welcome to my site</p> <p>Second paragraph</p>
2. Image missing alt
<img src="logo.png">
<img src="logo.png" alt="Our logo">
3. Duplicate id (each id must be unique)
<div id="main">…</div> <div id="main">…</div>
<div id="main">…</div> <div id="sidebar">…</div>
4. Wrongly nested / crossed tags
<b><i>Bold italic</b></i>
<b><i>Bold italic</i></b>
5. Missing <!DOCTYPE html> or charset
<html> <head> <title>My Page</title>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Page</title>
Make validating a habit, not a last step
Validate as you build, not just before you submit. The loop is simple:
Pre-submit checklist
- Page starts with
<!DOCTYPE html>and has<html lang="en"> -
<meta charset="UTF-8">and the viewport meta are in the<head> - Every tag that opens also closes, nested in the right order
- Every
<img>has meaningfulalttext - Every
idis used only once per page - HTML validator shows 0 errors; CSS validator is clean too