Creating XHTML document

An XHTML document is, in fact, an XML document, so it should start with an XML declaration that includes the used character encoding:

<?xml version="1.0" encoding="ISO-8859-1"?>

According to XHTML standards, each XHTML document requires a document type declaration (DTD). The "DOCTYPE" begins the XHTML document and tells a browser what type document it is. We add the following lines to every XHTML document designed in this course:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

See Choosing a DOCTYPE for more information.

Any web page written in XHTML language starts with the opening <html> tag and ends up with the closing </html> tag. The opening tag accepts a parameter name space (we will cover its meaning later), so the complete opening tag is like this:

<html xmlns="http://www.w3.org/1999/xhtml">

The web page consists mainly of two parts: the header and the body. The header starts with the opening <head> tag and ends up with the corresponding closing </head> tag.

You should put the title for your web page into the header surrounding it by the opening <title> and closing </title> tags. The title will then appear in the title line of a browser and can be used by the web search engines.

The opening and closing tags for the body are <body> and </body> respectively. All the information to appear in the main browser window should be put between these tags.

You can specify the main window background and text colors within the opening <body> tag. The colors can be specified either by name (e.g. "green" ) or by its RGB-code, e.g. "#ffffcc" for light yellow color.

Putting all together, a web page has the following structure:

XHTML tagsComments
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title> .... </title>
</head>

<body>





</body>
</html> 
XML declaration (required)
specifying the DOCTYPE (required)

opening tag to start XHTML script

opening tag for header
title for your webpage (required)
closing tag for header

opening tag for the document body

  more stuff to display



closing tag for body
closing tag for XHTML script

Within the body one can organize headings of the following 6 sizes:

LayoutXHTML tags

This is a h1 heading

<h1>This is a h1 heading</h1>

This is a h2 heading

<h2>This is a h2 heading</h2>

This is a h3 heading

<h3>This is a h3 heading</h3>

This is a h4 heading

<h4>This is a h4 heading</h4>
This is a h5 heading
<h5>This is a h5 heading</h5>
This is a h6 heading
<h6>This is a h6 heading</h6>