Content · Web Development · HTML

Checking HTML Document Validity

A valid document follows HTML syntax and content-model rules. Validation catches mistakes such as misplaced elements, repeated IDs, and incorrect attributes before they cause odd behavior.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

A valid document follows HTML syntax and content-model rules. Validation catches mistakes such as misplaced elements, repeated IDs, and incorrect attributes before they cause odd behavior.

What You Need to Know


A validator is a learning tool, not just a pass/fail badge. Read each message, find its location, and fix the underlying structure.

Think of an HTML document as a small book: the browser needs a title and some information about how to read it, while visitors need the actual chapters and text.

Example: See It in Action


Try this markup in a fresh practice file. The next section explains the parts worth paying attention to.

<!doctype html>
<html lang="en">
    <head><meta charset="utf-8"><title>Validity Check</title>
    </head>
    <body>
        <main>
            <h1>A valid start</h1>
        </main>
    </body>
</html>

Let’s Understand the Example


  • The html element holds the complete page and usually names its language.
  • The head contains useful page information for the browser, such as its title and character encoding.
  • A meta element gives the browser short information about the document. Different attributes control different hints.
  • Lang tells tools which language the text uses, helping pronunciation and language-aware features.
  • Charset tells the browser how to decode the page text; UTF-8 is the usual choice.

Some of the markup affects the browser tab or page settings rather than appearing as visible text. Check the browser tab and inspector as well as the page itself.

What Should You See?


The browser tab should show “Validity Check”. The page itself shows “A valid start” as a heading; those two labels are allowed to be different.

Open the page and compare what appears in the browser tab with the heading inside the document. Both have different jobs.

Try It Yourself


  1. Introduce an invalid nested paragraph and inspect the error, then repair it.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Ignoring validation messages because the page looks okay in the browser.
  • The title in the browser tab and the heading visible in the page are different pieces of information.

Key Takeaways


  • A valid document follows HTML syntax and content-model rules.
  • The html element holds the complete page and usually names its language.
  • A validator is a learning tool, not just a pass/fail badge. Read each message, find its location, and fix the underlying structure.
Share this resourceSend this page to someone who may find it useful.