Structure of an HTML Document
An HTML document requires 3 tags in order to be displayed correctly.
<HTML> - This tag always begins the document. This tells the browser that everything below it (until the /html) is going to be in html format.
<HEAD> - This is the heading of the document. This is where information such as the title of the web page, the name of the creator, etc. is seen. Nothing in the <HEAD> tag seen by the user viewing the page.
<BODY> - This is where the body of the document is located. All text and graphics are contained within the <BODY> tag.
Here is how the standard HTML hierarchy works:
| <HTML> <HEAD> </HEAD> <BODY> <B>My home page</B> </BODY> </HTML> |
The <HEAD> Tag
As stated before, the <HEAD> tag contains information not necessarily seen by the user. The only tag ever contained in the HEAD tag that would be seen by the user is the TITLE tag, which displays the title of the page on the top of most browsers.
There is plenty of other information that can be stored there:
-
Name, description and keywords of the document. This information is used mostly for search engines, such as Yahoo or Lycos.
-
Define relationships between other documents.
-
Define a script function, which is far too advanced to cover in this tutorial.
The TITLE tag, as I mentioned, is where the name of the document is stored.
This displays on the top of the browser window.
Here is an example of how the TITLE tag is used:
| <HTML> <HEAD> <TITLE>My home page</TITLE> </HEAD> <BODY> </BODY> </HTML> |
As mentioned, there are several tags one can include in the <HEAD> container that will determine how the page is displayed on a search engine. This is done with <META> tags. The 2 most widely used <META> tags are DESCRIPTION and KEYWORDS. The META tag is a way for the creator of the page to define information that is not included in the HTML document. Many meta features are advanced, and will not be discussed in this tutorial. Only the DESCRIPTION and KEYWORDS elements will be discussed.
Here is how one would include a description of the document:
| <META NAME="Description" CONTENT="My name is Aaron and this is my home page. Come on by and see what I'm like."> |
The Name field is how the tag is defined, and the Content field is where the information is kept. If this page were registered in a search engine, the title would be displayed as: 'My home page.' The description of the page would be displayed as: 'My name is Aaron and this is my home page. Come on by and see what I'm like.'
Meta tags do not require that you close them with a </> tag. They are not container tags.
The Keywords determine what searchable words could find your site. If you created a gardening site, you would probably use 'garden' as one of your keywords. Here is how Keywords are defined:
| <META NAME="Keywords" CONTENT="home page, me"> |
If anyone used the words 'home page' or 'me' to search for a page, this page might be one of the search results. Naturally you have to think logically when it comes to keywording your page. Few people are going to search with the word 'me.'
Here is how the page looks with the META commands included.
| <HTML> <HEAD> <TITLE>My home page</TITLE> <META NAME="Description" CONTENT="My name is Aaron and this is my home page. Come on by and see what I'm like."> <META NAME="Keywords" CONTENT="home page, me"> </HEAD> <BODY> </BODY> </HTML> |
The <BODY> Tag
In addition to being the container where the BODY of the document resides, you also define specific information for the look and feel of the page within the <BODY> tag. There are several attributes you can include. We will cover some of them.
Here are some attributes of the BODY tag:
ALINK - Defines the color of the link that is currently active.
VLINK - Defines the color of a link that has already been
visited
LINK - Defines the color of a link that hasn't been visited
yet.
TEXT - Defines the color of the text.
BGCOLOR - Defines the background color of the HTML document.
BACKGROUND - Points to the filename (URL) of an image to use
as the background.
BGPROPERTIES - When set to 'FIXED', the background image will
not scroll.
LEFTMARGIN - Sets the width of the left margin (pixels only)
TOPMARGIN - Sets the width of the top margin (pixels only)
Here is an example of an HTML document with some of the BODY attributes being used:
| <HTML> <HEAD> <TITLE>My home page</TITLE> <META NAME="Description" CONTENT="My name is Aaron and this is my home page. Come on by and see what I'm like."> <META NAME="Keywords" CONTENT="home page, me"> </HEAD> <BODY alink="white" vlink="brown" link="blue" text="black" bgcolor="yellow" leftmargin="10" topmargin="10"> My Home Page - I should be in Black. <a href="/img_articles/6155/1-3.htm">I am a visited link (brown) if you looked at the last sample page</a> <a href="/img_articles/6155/1-5.htm">I should be unvisited (blue) unless you've jumped ahead.</a> <a href="/img_articles/6155/1-4.htm">I should be the active link (white)</a> I should be black and the background should be yellow. </BODY> </HTML> |
I hope this came in useful!

