Browsers never reject bad HTML; the parser silently repairs it, not always the way you meant. A validator reports those mistakes first. The W3C's Nu Html Checker 189 runs at validator.w3.org/nu (https://validator.w3.org/nu/ 189 ), where you paste markup, upload a file or enter a URL. It also works as a web service you can call from a script or CI job. Every line of this page renders without complaint, yet it holds six errors (the optional <head> and <body> tags are legally omitted):
<!doctype html>
<html lang="en">
<meta charset="utf-8"><title>Order form</title>
<img src="logo.png">
<p>Ship to: <b>Home</p></b>
<input type="number" min="1" max="abc">
<center>Thanks!</center>curl -H "Content-Type: text/html; charset=utf-8" --data-binary @bad.html \
"https://validator.w3.org/nu/?out=gnu":4.1-4.20: error: An "img" element must have an "alt" attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. :5.20-5.23: error: End tag "p" seen, but there were open elements. :5.13-5.15: error: Unclosed element "b". :5.24-5.27: error: No "b" element in scope but a "b" end tag seen. :6.1-6.39: error: Bad value "abc" for attribute "max" on element "input": Expected a minus sign or a digit but saw "a" instead. :7.1-7.8: error: The "center" element is obsolete. Use CSS instead.
Positions are line.column ranges; out=json returns machine-readable results. To keep pages off a public server, run the same open-source checker (validator/validator (https://github.com/validator/validator 1,986 )) locally: npm 2,036 install vnu-jar 1,986 and java -jar node_modules/vnu-jar/build/dist/vnu.jar bad.html (Java 17 or later), or the ghcr.io/validator/validator Docker 514 image. Validation checks syntax, not accessibility, so pair it with Lighthouse 30,824 (Network and Lighthouse).