XHTML Basics

In this section we'll cover the XHTML basics - these important concepts can often account for more then half of the work a Web developer does in making a Web page!

The XHTML Foundation

XHTML pages can be divided into two sections: the head and the body. The head section is where you define the title of your page, write scripts, associate stylesheets, and include meta information which describes the contents of your page to search engines, etc. The body of your XHTML document encloses the content of your page, i.e. the stuff that your visitors will see and read, like graphics and text. Here's what the XHTML code looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
        (Insert the page's head information here ...) 
    </head> 
    <body>
        (Insert the page's body content here ...) 
    </body> 
</html>

Let's take a moment to review the basic syntax for the XHTML foundation.

Creating the XHTML <head> element

  • Immediately after the opening <html> element, type the <head> tag.
  • Insert the contents of the <head> section - we'll discuss this shortly.
  • Type </head> to close the element.

Creating the XHTML <body> element

  • Under the closing </head> tag, open the <body> element.
  • Insert the contents of the <body> section - again, we'll discuss this shortly.
  • Type </body> to close the body tag.

Creating the XHTML <title> element

Much like notebook computers are not very useful without their laptop batteries, XHTML pages are not very useful without a meaningful title. All XHTML pages require a <title> element - we recommend that you choose something short and descriptive, since in most browsers, the title is rendered in the browser's title bar, which has limited space. Here is an example of the <title> element:

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Learning the XHTML Basics</title>
</head>

To create a title element:

  • Type <title> anywhere between the opening and closing <head> tags.
  • Enter the name of your web page.
  • Type </title> to close the title.
Advertisement

Inquire about advertising on Web Head Start.

XHTML Topics

  1. Why XHTML?
  2. XHTML Basics
  3. XHTML Example
  4. Declaring a DocType
  5. XHTML Encoding
  6. XHTML Headers
  7. XHTML Comments
  8. XHTML Divisions
  9. XHTML Span
  10. XHTML 1.1
  11. XHTML Guidelines
  12. XHTML FAQ