[{"data":1,"prerenderedAt":238,"buildId":239},["ShallowReactive",2],{"page-\u002Flearn\u002Fhtml-validator":3},{"id":4,"title":5,"body":6,"description":221,"extension":222,"how_to_steps":223,"hub":210,"meta":224,"navigation":225,"path":226,"primary_keyword":227,"published_at":228,"schema_types":229,"seo":232,"status":233,"stem":234,"updated_at":235,"wave":236,"__hash__":237},"pages\u002Flearn\u002Fhtml-validator.md","HTML Validator: Check Your Markup the Right Way",{"type":7,"value":8,"toc":213},"minimark",[9,13,18,30,37,47,61,68,72,83,86,93,101,110,114,117,128,143,156,160,174,184,195,199,202,205],[10,11,12],"p",{},"An HTML validator checks your markup against the rules for writing HTML.\nRun it on the page you intend to serve, even if that page already looks right in your browser.\nBrowsers often recover from markup mistakes.\nA preview that looks fine can hide a problem in the document the browser built.",[14,15,17],"h2",{"id":16},"what-validation-checks","What validation checks",[10,19,20,21,25,26,29],{},"The HTML Living Standard describes which elements can go inside others and which attributes those elements can have.\nA validator, also called a conformance checker, tests the markup it receives against rules like these.\nIt can report an ",[22,23,24],"code",{},"li"," outside a list, an attribute it does not recognize, or a value where the standard requires a different format.\nIt can also spot two elements with the same ",[22,27,28],{},"id"," in one document.\nThen an in-page link or a label may not point to the element you meant.",[10,31,32,33,36],{},"Try this short page to see why opening a file is a different check from validating it.\nSave it as ",[22,34,35],{},"hours.html"," and open it in a browser, then paste the full document into a checker.",[38,39,45],"pre",{"className":40,"code":42,"language":43,"meta":44},[41],"language-html","\u003C!doctype html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n  \u003Cmeta charset=\"utf-8\">\n  \u003Ctitle>Library hours\u003C\u002Ftitle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cmain>\n    \u003Ch1>Library hours\u003C\u002Fh1>\n    \u003Cp>Pick a day:\n      \u003Cul>\n        \u003Cli>Tuesday: noon to six\u003C\u002Fli>\n        \u003Cli>Saturday: ten to four\u003C\u002Fli>\n      \u003C\u002Ful>\n    \u003C\u002Fp>\n  \u003C\u002Fmain>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html","",[22,46,42],{"__ignoreMap":44},[10,48,49,50,53,54,57,58,60],{},"You can see the hours in the browser even though a paragraph cannot contain a ",[22,51,52],{},"ul",".\nThe HTML parsing rules end the paragraph when the list starts.\nThe final ",[22,55,56],{},"\u003C\u002Fp>"," no longer closes the paragraph you wrote.\nThe checker can point at that closing tag even though the mistake began earlier.\nMove ",[22,59,56],{}," to the end of the line with \"Pick a day:\" and validate the page again.\nThe list should still appear in the browser.\nThe checker should no longer complain about an unmatched paragraph end tag.",[10,62,63,64,67],{},"A checker can find a missing attribute in a plain case, such as an image with no ",[22,65,66],{},"alt",".\nIt cannot judge whether the replacement text is useful.\nIt also cannot tell you whether a booking link leads to the right form.\nIt cannot judge whether text is readable on a phone or whether a visitor can finish the form with a keyboard.\nKeep those tasks on the test list after validation passes.",[14,69,71],{"id":70},"the-validators-worth-using-in-2026","The validators worth using in 2026",[10,73,74,75,82],{},"Start with the ",[76,77,81],"a",{"href":78,"rel":79},"https:\u002F\u002Fvalidator.w3.org\u002Fnu\u002F",[80],"nofollow","Nu HTML Checker"," for pages written to the HTML Living Standard.\nTo check a small example, paste the full HTML document into the text input.\nChoose file upload if you already saved an HTML file.\nUse the address option for a public page the checker can fetch.\nFor the library example, check both versions with the same input method so the only difference is where the paragraph closes.",[10,84,85],{},"The address option checks the response the service gets.\nThat may not match what you see when you are signed in.\nIf the result mentions a title or a form you do not recognize, check the URL.\nIt may redirect to a sign-in page or a generic error page.\nFor private pages, use a local checker approved for that material instead of sending the markup to a public service.\nEven a page meant only as a preview may contain names or links that should stay private.",[10,87,88,89,92],{},"Nu can also run locally as ",[22,90,91],{},"vnu.jar",", distributed by the Nu HTML Checker project.\nWith Java installed and the checker JAR in your current directory, run this on the saved example:",[38,94,99],{"className":95,"code":97,"language":98,"meta":44},[96],"language-sh","java -jar vnu.jar hours.html\n","sh",[22,100,97],{"__ignoreMap":44},[10,102,103,104,109],{},"Use the local option again when you need to check a batch of generated pages without uploading them.\nIf a build uses a different version than the one behind the web interface, compare the rules and tool versions.\nTheir reports may not match word for word.\nIf you must check a document against an old doctype such as HTML 4.01 Transitional, use the ",[76,105,108],{"href":106,"rel":107},"https:\u002F\u002Fvalidator.w3.org\u002F",[80],"W3C Markup Validation Service"," in that legacy mode.\nA result under old rules answers a different question from whether the same page meets today's HTML requirements.",[14,111,113],{"id":112},"errors-that-matter-vs-noise","Errors that matter vs noise",[10,115,116],{},"Start with the first error that can change how the browser reads the rest of the document.\nA stray closing tag or a missing quotation mark can make later messages look unrelated.\nThis is worse when a shared header sits above all the page content.\nRead the lines before and after the position in the report, fix one suspected cause, and run the checker again.\nIf several later errors disappear together, you can leave their lines alone.",[10,118,119,120,123,124,127],{},"After parsing errors, fix problems that can change what people read or click.\nIf two forms include ",[22,121,122],{},"id=\"email\"",", give the fields distinct IDs.\nUpdate the ",[22,125,126],{},"for"," attributes on their labels.\nAlso update any code or links that use those IDs.\nIf you find a button wrapped inside a link, give each action one control.\nA link can take the reader to the booking page, where a submit button can send the completed form.\nIf both actions are needed, give them separate controls with names that make the difference clear.",[10,129,130,131,134,135,138,139,142],{},"Read warnings in context.\nA warning about the trailing slash in ",[22,132,133],{},"\u003Cimg src=\"shelf.jpg\" alt=\"\" \u002F>"," does not mean the browser treats the image as unclosed.\n",[22,136,137],{},"img"," is a void element, which has no end tag in HTML.\nUse ",[22,140,141],{},"\u003Cimg src=\"shelf.jpg\" alt=\"\">"," for plain HTML if you want to avoid that warning.\nIf an attribute value is unquoted and the slash is attached to it, the slash can become part of the value.\nCheck the source before you dismiss the warning.",[10,144,145,146,150,151,155],{},"The site's opening checklist ",[76,147,149],{"href":148},"\u002Fwiki\u002Findex.php\u002FOpening_Preparations","from the 2007-2009 archive"," includes validation work for its mailing list pages.\nIn ",[76,152,154],{"href":153},"\u002Fpipermail\u002Flist_html4all.org\u002F2008-April\u002F000705.html","the original mailing list discussion",", contributors distinguished rules a checker can apply from requirements that need human judgment.\nUse the current checker and standard when deciding whether a report on a new page needs action.\nOlder documents make useful comparisons.\nBut their markup and the rules it was written for may differ from yours.",[14,157,159],{"id":158},"validating-ai-generated-html","Validating AI-generated HTML",[10,161,162,163,165,166,169,170,173],{},"Check the complete output after you have placed it in your project.\nA generator might return a bare fragment, which can be right for a component.\nIt might instead return a full page with ",[22,164,43],{},", ",[22,167,168],{},"head",", and ",[22,171,172],{},"body",".\nA full page does not belong inside an existing page template.\nA card can look fine on its own.\nIt can still produce duplicate IDs when the same card appears six times on a page.\nValidate the assembled page so the checker can see those interactions.",[10,175,176,177,180,181,183],{},"Ask the tool for a small fix to the specific source of an error.\nFor instance, if the booking card repeats ",[22,178,179],{},"id=\"slot\"",", ask for unique IDs with matching ",[22,182,126],{}," attributes for each date selector.\nRead the diff to make sure it did not remove the visible labels to silence a message.\nThen build the page again and click each label to check that it focuses its own field.",[10,185,186,187,189,190,194],{},"Review text that a generator supplies to satisfy required markup.\nAn empty ",[22,188,66],{}," is right for a purely decorative image.\nIt is not a fix for a photo or diagram that carries information the page does not give elsewhere.\nIf the generated text says only \"photo,\" decide what the picture contributes to the reader's task before rewriting it.\nUse the ",[76,191,193],{"href":192},"\u002Flearn\u002Falt-text-best-practices","alt text best practices"," guide to work through that decision.",[14,196,198],{"id":197},"validation-in-your-workflow","Validation in your workflow",[10,200,201],{},"For a hand-written page, save it, run the checker, and fix errors before you rely on what you see in the browser.\nFor a site built from templates, point the checker at the generated HTML once the build has filled in the template's placeholders.\nStart with one page per template, including a version with real lists, images, or form fields if the template can render those.\nA mostly empty example may never exercise the code that produces invalid markup.",[10,203,204],{},"In continuous integration, run the checker after the build so new pages and template changes are checked before publishing.\nChoose a policy that blocks new errors and sends warnings to review instead of hiding the entire report.\nWhen a shared component causes the same error on dozens of pages, correct the component and rebuild.\nEditing each generated file leaves the cause in place for the next build.\nIf a script adds markup after the page loads, the first HTML check will not see it.\nTest the affected state in the browser too.",[10,206,207,208,212],{},"Finish by navigating without a mouse, following the important links, and trying the form with both a valid and an incomplete entry.\nA passing workflow means the chosen pages have no validation errors.\nYou have reviewed the remaining warnings.\nThe page still works when you try the tasks visitors came to do.\nFind another practice page in the ",[76,209,211],{"href":210},"\u002Flearn","Learn HTML hub"," and try the same checks there.",{"title":44,"searchDepth":214,"depth":214,"links":215},2,[216,217,218,219,220],{"id":16,"depth":214,"text":17},{"id":70,"depth":214,"text":71},{"id":112,"depth":214,"text":113},{"id":158,"depth":214,"text":159},{"id":197,"depth":214,"text":198},"What an HTML validator actually checks, which tools to use in 2026, and how to fix the errors that matter and ignore the noise.","md",null,{},true,"\u002Flearn\u002Fhtml-validator","html validator","2026-12-01T05:35:41Z",[230,231],"Article","BreadcrumbList",{"title":5,"description":221},"draft","learn\u002Fhtml-validator","2026-12-01T06:15:12Z","1","VfwaX2Qo68DWi8Q_U_peYl6m4fmVYhIJvEMN1kTTei0",1796185435705,"a1d53563-3a78-4678-8315-e5bd6a5bd80c"]