Chapter 4. Validity

Validity goes beyond mere well-formedness to ensure that a document is not merely syntactically correct but semantically correct. It promises that only elements and attributes defined in the HTML specification appear so that browsers aren’t taken by surprise. It also promises that they appear only in certain places where their meaning is well defined. For example, in a valid document you won’t find a table in the head or a blockquote in a paragraph.

Validity offers many advantages to site authors and even more advantages to site consumers. First, valid sites are predictable. They show the same content to users with different browsers. Although details regarding font size and positioning can vary from one browser to another, ...

Get Refactoring HTML: Improving the Design of Existing Web Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.