Global Structure

Your HTML document should consist of three parts:

We'll look at each of these in turn, but first, let's examine a sample document:

<...version info goes here...>
<HTML>
 <HEAD>
   ...information about document goes here...
 </HEAD>
 <BODY>
   ...content of document goes here...
 </BODY>
</HTML>

Note that, with the exception of the version info, all these tags follow the container model. That is, there's an opening tag and a closing tag, and other information is contained between the tags. The head is delimited by the <HEAD> and </HEAD> tags, and the body is delimited by the <BODY> and </BODY> tags. Note also that both the head and body are delimited by the <HTML> and </HTML> tags.

(I'll let you in on a little-known secret. None of the tags shown above are necessary to create a functional web page! As long as the stuff between the <BODY> and </BODY> tags is written correctly, the <BODY> and </BODY> tags themselves are superfluous. The main reason we use these tags is to help ourselves stay organized.)

Version Info

Since there are a number of different versions of HTML, it's a good idea to declare what version of HTML you're using right away. The very first item in your document should be a declaration of version information, which might look something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
               "http://www.w3.org/TR/REC-html40/strict.dtd">

I know, it looks unintelligible. Keep in mind that you don't need to type this out yourself. You'll want to use a template instead.

Head

The head of the document contains information about the document. What kind of information? That's up to you, mostly. One item you must supply is a title:

<HEAD>
  <TITLE>War and Peace</TITLE>
</HEAD>

The title element is required for every HTML 4.0 document. There are also other optional elements, such as the META element, which you may choose to include in the head of your document; these are not covered in this introductory tutorial.

Body

The body of the document contains the actual content of the document. This might be text, images, or multimedia objects.

<BODY>
   ...paste text here...
</BODY>

A good way to get started is to paste the raw text of your document between the <BODY> and </BODY> tags of a template. Then continue to mark up the text with HTML.

HTML

As noted above, both the head and body are delimited by the <HTML> and </HTML> tags. The first thing in your HTML file (after your version info) should be the opening <HTML> tag. The last item in your file should be the closing </HTML> tag.

If you omit this element, you page will still work, but it's considered good form to include it.

<HTML>
...head and body go here...
</HTML>

| Introduction to HTML | Tutorials |