3.3 Semantic Markup

In Figure 3.2, some of the yellow sticky note and red ink markup examples are instructions about how the document will be displayed (such as, “main heading” or “bulleted”). You can do the same thing with HTML presentation markup, but this is no longer considered to be a good practice. Instead, over the past decade, a strong and broad consensus has grown around the belief that HTML documents should only focus on the structure of the document; information about how the content should look when it is displayed in the browser is best left to CSS (Cascading Style Sheets), a topic introduced in the next chapter, and then covered in more detail in Chapter 7.

As a consequence, beginning HTML authors are often counseled to create semantic HTML documents. That is, an HTML document should not describe how to visually present content but only describe its content’s structural semantics or meaning. This advice might seem mysterious, but it is actually quite straightforward.

Examine the paper documents shown in Figure 3.7. One is a page from the United States IRS explaining the 1040 tax form; another is a page from a textbook (Data Structures and Problem Solving Using Java by Mark Allen Weiss, published by Addison Wesley). In each of them, you will notice that the authors of the two documents use similar means to demonstrate to the reader the structure of the document. That structure (and, to be honest, the presentation as well) makes it easier for the reader to quickly grasp the hierarchy of importance as well as the broad meaning of the information in the document.

Figure 3.7 Visualizing structure

The figure shows 3 sheets of paper overlapping each other with content written using different structure and format.
Figure 3.7 Full Alternative Text

Structure is a vital way of communicating information in paper and electronic documents. All of the tags that we will examine in this chapter are used to describe the basic structural information in a document, such as headings, lists, paragraphs, links, images, navigation, footers, and so on.

Eliminating presentation-oriented markup and writing semantic HTML markup has a variety of important advantages:

But enough talking about HTML . . . it is time to examine some HTML documents.