The HTML Document

So far, you’ve been considering HTML snippets—portions of a complete HTML document. In this section, you’ll learn how to put it all together and create your first genuine web page.

The Document Type Definition

In the early days of the Internet, web browsers were riddled with quirks. When people designed web pages, they had to take these quirks into account. For example, browsers might calculate the margins around floating boxes of text in subtly different ways, causing pages to look right in one browser, but appear odd in another.

Years later, the rules of HTML (and CSS, the style sheet standard you’ll consider in Chapter 6) were standardized in more detail. Using these new rules, every browser could display the same page in exactly the same way. But this change caused a serious headache for longstanding browsers that had lived through the dark ages of HTML, like Internet Explorer. These browsers had to somehow support the new standards, while still being able to properly display existing web pages—including those that relied on old quirks.

The web community settled on a simple solution. When designing a new, modern web page, you indicate this fact by adding a code called a document type definition (DTD) or doctype, which goes at the very beginning of your HTML document (Figure 2-6).

The document type definition (DTD) is the first piece of information in an HTML file. It tells the browser what markup standard you used to write the page.

Figure 2-6. The document type definition (DTD) is the first piece of information in an ...

Get Creating a Website: The Missing Manual, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.