HTML Tutorial / Find Errors and Validate an HTML Document
HTML validation helps find markup mistakes that a browser may quietly repair, such as malformed attributes, unexpected closing tags, or duplicate IDs. After fixing reported issues, you still need to check the page's actual content and interactions in a browser.
Save and inspect the page first
Save the current HTML file and open it in a browser. Check that headings, paragraphs, links, images, and forms appear where expected. A visible page is not proof that its markup is valid: browsers can recover from some errors and display a result different from the structure you intended.
Run the Nu HTML Checker
The Nu HTML Checker can inspect a public URL, an uploaded file, or pasted markup. For a local or unpublished document, use file upload or direct input. Do not upload source files containing passwords or personal data to a public validation service. The tag and attribute rules being validated are introduced in Syntax.
- Save the latest version of the HTML file.
- Select the appropriate input method and start the check.
- Read each message and inspect the reported location plus nearby opening and closing tags.
- Fix the file, save it, and run the check again.
Start with the earliest error when many messages appear. A single malformed attribute can cause several later messages. The line where an error is detected may not be the line that caused it; an unclosed quotation mark, for example, can make the next tag appear invalid. Make sure you reupload the saved revision rather than repeatedly validating an older file.
For instance, this markup repeats one id:
<label for="email">Email</label>
<input id="email" name="email" type="email">
<label for="email">Confirm email</label>
<input id="email" name="email_check" type="email">
Change the second field's ID to email-check and update its label's for to match. Then check that the duplicate-ID error is gone and that each label focuses its own input. A short tag is not automatically wrong: some elements, including li in certain contexts, may omit their closing tag under HTML rules.
Checking the complete examples with the Nu HTML Checker returned Duplicate ID “email”. for the failing document and no errors for the correction. Compare the label interactions separately; additional diagnostics can vary with checker updates or different file contents.
Compare a failing document with its correction
The following validation exercise deliberately repeats an ID. Save it as invalid.html and check it using the Nu HTML Checker's text-input or file-upload mode. It is a failing test case, not code to deploy unchanged.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document-validation practice</title>
</head>
<body>
<h1>Label-validation practice</h1>
<form method="get">
<p><label for="email">Email</label>
<input id="email" name="email" type="email"></p>
<p><label for="email">Confirm email</label>
<input id="email" name="email_check" type="email"></p>
<button type="submit">Inspect entered values</button>
</form>
</body>
</html>
Find the diagnostic about using email twice as an ID. A browser may still show two fields, but that does not correctly associate each name with its own field. The corrected document changes the second field and label target to email-check.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document-validation practice</title>
</head>
<body>
<h1>Label-validation practice</h1>
<form method="get">
<p><label for="email">Email</label>
<input id="email" name="email" type="email"></p>
<p><label for="email-check">Confirm email</label>
<input id="email-check" name="email_check" type="email"></p>
<button type="submit">Inspect entered values</button>
</form>
</body>
</html>
- Save the correction as valid.html and validate the latest file rather than the earlier copy.
- Click each label and compare which input receives focus. Changing an ID without updating for leaves the association wrong.
- After the diagnostic is resolved, still test destinations, content, and keyboard use. Record syntax and usability results separately.
| Problem | Inspect first | Correction principle |
|---|---|---|
| Duplicate ID | id / for |
Make the ID unique and update each reference |
| Missing quotation mark | The reported line and preceding attribute | Look for an unterminated value before blaming the next tag |
| Empty action value | form action="" |
Omit action when targeting the current document |
Do not confuse an intentionally failing example with broken formatting in the article itself. A code block can show the string that reproduces an error; the validation target is the standalone document created from that example.
Validation is only one kind of check
A syntax checker cannot guarantee that a link reaches the right article, alt text explains an image, or a server handles a form correctly. Open links, use the page with a keyboard, and check a narrow viewport. For missing media, investigate paths, server responses, and supported formats as well as markup. Apply both syntax checks and real navigation testing in Build a Small Multipage Website.
Know what you validated: a file upload checks that file, while a URL check inspects the document a server actually returns. On WordPress, a theme wraps the article body, so checking a manuscript fragment and checking the complete published page can produce different results. Separate problems in the article from issues introduced by the theme or a plugin.




