Forms and debugging

Validate your HTML

Use an HTML validator to find invalid nesting, missing attributes, duplicate IDs, and other mistakes a forgiving browser may silently repair.

7 minute lesson

~~~

Browsers try to render invalid HTML. That is useful for visitors, but it can hide mistakes from you.

An HTML validator checks your source against the standard. Use the Nu HTML Checker and either paste your markup, upload a file, or enter a public URL.

The checker can find problems such as:

  • elements nested where they are not allowed
  • missing required attributes
  • duplicate IDs
  • obsolete elements or attributes
  • unclosed tags that change the document tree

Read the first error first. One broken tag can cause several later messages, and fixing it may remove the others.

A validator checks syntax and structural rules. It cannot tell whether your heading is useful, your link text is clear, or your alt text describes the important part of an image.

Treat validation as one part of the review:

  1. validate the markup
  2. inspect the page in the browser
  3. use it with the keyboard
  4. read the content as a visitor would

Valid HTML is not automatically good HTML, but invalid HTML makes good results harder to trust.

Lesson completed