O'Reilly logo

Web Design in a Nutshell, 2nd Edition by Jennifer Niederst Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting Up an HTML Document

The standard skeletal structure of an HTML document according to the HTML 4.01 specification is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/HTML4.01/strict.dtd">
<HTML>
  <HEAD>
    <TITLE>Document Title</TITLE>
  </HEAD>
  <BODY>
    Contents of Document...
  </BODY>
</HTML>

This document has three components: a document type declaration (<!DOCTYPE>), the header section (<head>), and the body of the document (<body>).

The HTML standard requires that the entire document appear within the <html> container, but most browsers can properly display the contents of the document even if these tags are omitted. All HTML documents are made up of two main structures, the head (also called the “header”) and the body. The exception to this rule is when the document contains a frameset in place of the body. For more information about framesets, see Chapter 14.

The Document Type Declaration

In order to be valid (i.e., to conform precisely to the HTML standard), an HTML document needs to begin with a document type declaration that identifies the version of HTML that is used in the document. There are three distinct versions of HTML 4.01 (Strict, Transitional, and Frameset), each defined by a distinct document type definition (DTD). The DTD documents live on the W3C server at a stable URL.

The document’s DTD is specified at the beginning of the document using the SGML declaration <!DOCTYPE> (document type). The remainder of the declaration contains ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required