HTML and CSS Reference
The various computer languages used on the Web, including but not limited to (X)HTML, CSS, RDF, and RSS,
provide structure, style, metadata, semantics, and other document features. Similar to natural languages, they have
their own grammar, vocabulary, and syntax that need to be followed. However, just like the grammar, structural, or
spelling errors that occur in documents written in natural languages, web documents might also have errors in them.
Validation is the task of checking the source code of web documents against a DTD or schema. It contributes to
error-free, clean code and increases overall web page quality.
Even a single character might affect your carefully created standard-compliant code, so it is important to
regularly check your documents. After achieving the necessary routine, you are able to modify or extend web
documents at the source level without violating standard compliance. In this chapter, you will learn about the tools
that help you locate and correct errors if they occur and can assure you whether your code is error-free.
Markup language grammar rules are defined by Document Type Definitions (DTDs). Prior to HTML5/XHTML5,
developers should have provided a reference to the DTD associated with the document type being used (as discussed
in Chapter 3).
Web documents can be verified against these rules, which is called validation . The tools used to perform
validation are called validators . Documents successfully passing validation are claimed to be valid ; in other words,
they are free of errors and do not contain incorrectly used elements or attributes. However, validation guarantees
neither well-structuredness nor proper element use . A valid document follows the grammar rules outlined in the
corresponding DTD, which makes it possible for user agents to construct the DOM correctly and render the
Applying the grammar rules defined in DTDs is described in technical specifications , most of which are published
Standard conformance is the feature of those web documents that fulfill all the requirements described by the
appropriate DTD and specification. A web document is valid when it is correctly written in accordance to the formal
grammar included in the technical specification of the corresponding markup language, whereas conformance relates
to the entire specification. Since some conformance requirements, such as the proper use of attribute values, cannot
be described by the formal grammar, validity is only part of conformance. Consequently, validity and conformance
might be identical, but the latter one is a wider term.
Valid documents are written according to the formal grammar of the language being used. Standard-compliant
documents apply the technology the recommended way.
Validation should not be considered as the final step right before web site launch. Instead, it should be performed
as an essential part of web site development. For beginners who cannot write new markup elements and attributes
correctly with 100 percent certainty, validation can help identify potential errors and prevent invalid markup from
being duplicated or multiplied. Even experienced web designers might find validation useful and consider it an
assistance rather than a mandatory task. After inserting new structural elements to the source, for example, it can be