KodingKaro
HTML · Intermediate · HTML Validation and Debugging

Common markup errors and validation

A browser may still show a page with invalid HTML, so visual appearance alone cannot confirm correct markup.

✓ What you will learn in this topic

  • Explain the purpose of Common markup errors and validation in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

Common problems include missing required attributes, invalid nesting, duplicate ids, and elements used outside their allowed context. Browsers repair many errors to keep pages usable, but repaired markup can behave unexpectedly. An HTML conformance checker reports errors and warnings against the standard. Fix structural errors rather than relying on browser recovery, and re-check after important template changes.

Syntax

Write valid parent-child relationships, unique ids, required attributes, and complete document structure.

Example 1: a small page

The phrasing is properly nested, with strong inside the paragraph.

<p>Bring a notebook and <strong>write questions</strong>.</p>

Expected result: The browser shows one paragraph with the phrase write questions emphasized.

Example 2: a practical page

Each li is placed within its list container, giving the browser a valid list structure.

<ul>
  <li>Collect leaves</li>
  <li>Label each sample</li>
</ul>

Expected result: A two-item unordered list appears and can be recognized as a list by assistive technology.

Common mistakes

Do not assume the browser’s repaired DOM exactly matches the source you wrote.

Best practices

Validate representative pages, inspect the DOM and console, and fix errors at their source instead of hiding warnings.

Practice exercise

Create a page containing three intentional markup errors, use browser developer tools and a validator to find them, then record the corrected markup.

Lesson summary

  • Browsers recover from errors, but validation helps you correct the original document structure.
  • Validate representative pages, inspect the DOM and console, and fix errors at their source instead of hiding warnings.

Knowledge check

Why is a page that looks correct not necessarily valid HTML?

Show the explanation

Browsers repair many errors, so visual output can hide invalid source or a different-than-intended document tree.

Practical example

html
<p>Bring a notebook and <strong>write questions</strong>.</p>

Expected result:

The browser shows one paragraph with the phrase write questions emphasized.

Hands-on practice task

Create a page containing three intentional markup errors, use browser developer tools and a validator to find them, then record the corrected markup.

In this section

Other lessons in HTML Validation and Debugging

Broaden your knowledge

Related learning topics