Logo HTML Topics: Starting a Document

Course Material Index  Section Index  Previous Page  Next Page

The Document Title

You should always begin your document with a title. The title of a document is shown on the top border of the browser window. The title of the document you are reading now was produced by beginning the document with:

         <TITLE>HTML Topics: Starting a Document</TITLE>

It's just a case of enclosing the appropriate text between <TITLE> and </TITLE>. All forms of formatted text are made simply by inserting these formatting codes, usually called tags, into your text.

Tags are not case sensitive. The web pages of this course are written with uppercase tags as a standard: the reason for this is that they are easily distinguished from the text proper, i.e. displayed text, in most text editors. However, many people working on Unix systems in particular, prefer to work solely in lowercase and hence use lowercase tags. Thus the following two title lines are identical to all Web browsers:

         <TITLE>This page is about writing HTML documents</TITLE>
 
         <title>This page is about writing HTML documents</title>

When writing HTML documents, try to be consistent regarding case, and never use a mixture of upper and lowercase within the same tag.

The Document Header

The title tags and text must appear in the document header area enclosed by <HEAD> and </HEAD> :

        <HEAD>
            Document header
        </HEAD>
 
The contents of the document header may continue over as many lines as required. So with a title, the header may look like this:
        <HEAD>
        <TITLE>HTML Topics: Starting a Document</TITLE>
        </HEAD>
 
The better search engines index your document according to the contents of the header, so it is worth while giving some thought to the wording of your title if and when you produce publically available web material.

The Document Body

The main body of your document must appear in the area enclosed by <BODY> and </BODY> :

        <BODY>
            Document body
        </BODY>
 
The contents of the document body may continue over as many lines as required. The browser will format the text in between the <BODY> and </BODY> tags into a neat, left-justified document.

Tags may also have attributes. The <BODY> tag has attributes to set the background colour (or pattern), hypertext link colours, and so on. It is quite useful to be able to set the background colour to white since the default colour for web documents is grey! An example of the use of the BGCOLOR attribute is shown below:

        <BODY BGCOLOR=WHITE>
            Document body
        </BODY>
You are strongly advised to use this attribute: remember that, in general, most web documents are printed on white paper. The use of colour will be discussed in more detail later in this section of the course. Note that the attribute is only supplied for the start (or opening) tag and not for the end (or closing) one.

Document Layout

The document header and body must be enclosed between the <HTML> and </HTML> tags, so that the layout of an HTML document is always as follows:

        <HTML>
            <HEAD>
                Document header
            </HEAD>
            <BODY>
                Document body
            </BODY>
        </HTML>
In each webpage, the HTML, HEAD, and BODY tags should normally occur only once. This is contrast to some of the other tags described in the subsequent webpages, which will often be used more than once per HTML page.

By now you should have observed the following points:


Course Material Index  Section Index  Previous Page  Next Page
© Copyright 1995-2006.  Birkbeck College, University of London.
 
 
 
 
Author(s): Jeremy Karl Cockcroft
Huub Driessen
Sami Raza
Oliver Theis
Ian Tickle