The fourth edition of this book represents a significant change in order to fully embrace XHTML. Although the previous edition presented XHTML, most of the examples were still in HTML 4 with explanations about differences with XHTML. Today the situation is reversed with the primary focus on the future of markup with XHTML, CSS, and XML rather than the past, filled with tricks and messy table code.
Interestingly, while many books have embraced XHTML, relatively few Web page authors have. Furthermore, at the time of this edition's writing many Web tools do not produce correct markup in traditional HTML, let alone XHTML. Yet the times are changing. During 2002 and 2003 the survivors of the dot com boom have come to take their trade very seriously and more and more sites are truly embracing Web standards.
This book was updated assuming the "embrace the standards" trend will continue. HTML 4 is still well covered and the important table techniques are still presented, but compared to other books on HTML, heavy focus on what Netscape 2 did seven or more years ago is completely purged. Furthermore the focus is very much away from Netscape\u2014especially given that it has been recently discontinued\u2014and more on Internet Explorer, Mozilla, and Opera. Because of this focus on the future, the fourth edition should be both valuable to the standards-conscious designer looking for a reference as well as the newcomer hoping to learn what they need to know for today and tomorrow.
Markup is information that is added to a document to convey information about the document's structure or presentation. Markup languages are all around us in everyday computing. While you may not see it, word processing documents are filled with codes indicating the structure and presentation of the document. What you see
on your screen just looks like a page of text, but the formatting is done "behind the scenes" by the markup. Hypertext Markup Language (HTML) and its successor, XHTML, are the not-so-behind-the-scenes markup languages that are used to tell Web browsers how to structure and, some may say, display Web pages.
In the case of HTML, markup commands applied to your Web-based content relay the structure of the document to the browser software and, though perhaps unfortunate at times, how you want the content to be displayed. For example, if you want to show that a section of text is important, you surround the corresponding text with the markup tags,<strong> and</strong>, as shown here:
When a Web browser reads a document that has HTML markup in it, it determines how to render the document onscreen by considering the HTML elements embedded within it (see Figure 1-1). Be aware that browsers don't always render things in the way that you think they will. This is due partially to the design of HTML and partially to the differences in the variety of Web browsers currently in use.
So we see that an HTML document is simply a text file that contains the information you want to publish and the appropriate markup instructions indicating how the browser should structure or present the document. These markup elements are made up of a start tag such as<strong>, and also might include an end tag, which is indicated by a slash within the tag such as</strong>. The tag pair should fully enclose any content to be affected by the element, including text and other HTML markup. However, under traditional HTML (not XHTML) some HTML elements have optional close tags because their closure can be inferred. Other HTML elements, called empty elements, do not enclose any content, and thus need no close tags at all, or in the case of XHTML, use a self-close identification scheme. For example, to insert a line break, use the<br> tag, which represents the emptybr element as it doesn't enclose any content and has no corresponding close tag.
<br />The start tag of an HTML element might containat tributes that modify the meaning of the tag. The inclusion of thenoshade attribute in the <hr> tag, as shown here,
indicates that there should be no shading applied to the horizontal rule element. Under XHTML, such existence style attributes are not allowed. All attributes must have a value, so instead we use a syntax like the following:
As the last example shows, attributes do require value and they are specified with an equal sign; these values should be enclosed within double or single quotes. For example,
specifies four attributes for the <img> tag that are used to provide more information about the use of the included image. A complete overview of the structure of HTML elements is shown here:
Given these basic rules for HTML tags, it is best now to simply look at an example document to see how they are used. Our first complete example written in transitional HTML 4 is shown here:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>First HTML Example</title>
<h1>Welcome to the World of HTML</h1>
<p>HTML <b>really</b> isn't so hard!</p>
<p>You can put in lots of text if you want to. In fact, you
This action might not be possible to undo. Are you sure you want to continue?