Document Structure
Write valid code

Building to standards means following a standard set of specifications that defines the syntax or rules for the structure of HTML or other code. One of the benefits of building to standards is that results can be measured against specifications to ensure that a project meets code. Web pages are built primarily using the standards for markup (HTML and XHTML) and presentation (CSS) developed by the World Wide Web Consortium (W3C). When Web pages are built to standards, they are more likely to function properly with browsers that also conform to specifications.

To ensure standards compliance, we need to begin each page with a DOCTYPE, or document type declaration. DOCTYPE tells software which set of specifications to use in handling pages:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xHTML1/DTD/xHTML1-transitional.dtd">

In the above example, the document type is identified (XHTML 1.0 Transitional) along with the URL for the DTD, or document type definition. For page access, DOCTYPE tells browsers which set of standards to follow, increasing the likelihood that pages will display properly across software and devices. For page validation, DOCTYPE tells validation software which set of specifications to measure against in assessing standards compliance.