Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > HTML/XHTML

Basic (X)HTML Structure

  • Print
  • + Share This
This chapter covers the most basic (X)HTML elements—the ones you need to create the structure of your document. You'll learn how to create new paragraphs, headers, page breaks, comments, and more.
This chapter is from the book

This chapter covers the most basic (X)HTML elements—the ones you need to create the structure of your document. You'll learn how to create new paragraphs, headers, page breaks, comments, and more.

Creating a clear and consistent structure makes it that much easier to apply styles to your document.

Starting Your Web Page

Begin your page by using a DOCTYPE (see page 40) to declare what type of HTML or XHTML you're using. The DOCTYPE lets browsers know what to expect and tells validators how to judge your code in order to check its syntax. Then, signal the beginning of the actual code with the opening html tag.

Figure 3.1

Figure 3.1 Here's the DOCTYPE for a transitional HTML document as well as the opening and closing html tags. It's a gruesome bit of text. I recommend just copying it from one document to the next instead of trying to type all that gobbledy-gook.

To start a transitional HTML 4 page:

  1. Type <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> to declare that you're using transitional HTML 4.01 in your Web page.
  2. Type <html> to begin the actual HTML portion of your document.
  3. Leave a few spaces for creating the rest of your page (using the rest of this book).
  4. Type </html>.

To begin a transitional XHTML page:

  1. Type <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> to declare that you're using transitional XHTML in your Web page.
  2. Type <html xmlns="http://www.w3.org/1999/xhtml"> to begin the XHTML portion of your page and declare its namespace.
  3. Leave a few spaces for creating the rest of your page (using the rest of this book).
  4. Type </html>.
Figure 3.2

Figure 3.2 Here's the DOCTYPE for a transitional XHTML document, the opening html tag and required namespace declaration, and the closing html tag.

  • + Share This
  • 🔖 Save To Your Account