H T M L

PAGE (5 of 8)

Common HTML Tags

Basic Tags

Below are the most commonly used HTML tags. Almost all of these tags will be found in every HTML document.

HTML

Most documents start with the html tag and end with the /html tag.

Head

Material in the head roughly corresponds to the title page of a document. The head and /head commands are used.

Body

The content of the document should appear between the body and /body tags.

Titles

Titles are used in the menu bar of the Web Browser window using title and /title. They are coded in the head.
   <head>
   <title>HTML Introduction</title>
   </head>

Headings

Headings appear in the body of the document. There are 6 levels of headings available but only the first 3 are generally used. The heading tags are h1 /h1, h2 /h2, etc. The h1 heading is frequently the same as the title.

Paragraphs

New paragraphs are started with the p tag. It does not require a closing tag, but you should enclose one for consistency.

Simple lists

Both numbered/ordered lists and bulletted lists are available, and they may be nested. An order list uses 3 tags: ol, li, and /ol. A bulletted list also uses three tags: ul, li, and /ul.

Definition lists

A definition list consists of a term and its definition. The dl, dt, dd, and /dl tags are used.

Character formatting

Words and characters may be highlighted using

Force a New Line

Text can be forced to a new line with the br tag. It does not have a closing tag.

Preformatted Text

The WWW client determines the display fonts used. If you have material that must be displayed using a uniform font (an "m" takes the same amount of space as an "i") you can enclose the text in the pre /pre tags. This is useful for tables or programming language source code. Other tags may be used inside the pre /pre tags but results are not always predictable. It is best to get the text lined up correctly and then add the other tags.

Horizontal lines

You can add a horizontal line to the document with the hr tag.

Adding Pictures Inline

Images are added to a document with the img tag, (like the U.S. icon at the right). It is a little more complicated than the text tags discussed so far.

<img align=top src="name_of_image_file.gif" alt="no picture">

src
this is the url of the graphic.
align
top, middle, or bottom. This relates to how the text and graph align. Optional.
alt
this text displays if the graphic is not found. Optional.

Adding Document Links

There are two types of document links:
  1. Inter-document Links
  2. Anchors (intra-document) links
Inter-document Links
Inter-document links are hyper-links between different documents on the WWW. These are created with the a and the /a tag pair.
     <a href="http://machine/directory/file.html">
     followed by text that is clickable
     </a> 
      
      
Anchor Links

Anchor links are intra-document hyper-links within the same document on the WWW. These are also created with the a and the /a tag pair.

     <a href="#anchorName">
     followed by text that is clickable
     </a> 
      
   

External Graphics, Sounds or Movies

Physically embedding large files (images, sounds, movies) can drastically increase the transfer time of documents across the net. The solution to this is to include links to the large files in your html document. The method is the same as described previously for adding document links, except that the file.html is replaced by file.ext. The .ext extension is replaced by the appropriate extension for the file type (e.g., .gif or .jpg, .au or .aiff, .mov, .mpeg or .mpg). It is the reader's responsibility to have their WWW browser configured with the appropriate helper application that can read and process the file format.

Tables

Tables can be used to present data in rows and columns. Tables may have captions/titles at the top or bottom. In addition, there can be column headings. Tables are enclosed in the TABLE tags. Other tags include the CAPTION, TH (column heading), TR (table row), and TD (cell definition) tags.


HTML and Netscape (optional)

Netscape HTML Editing Tutorials



Further Reading

There are many features of HTML not mentioned above. Most WWW clients provide a way for you to download a WWW document with the HTML tags. Find a few pages you think look good, download the document with tags, and see what tags were used.

Explore these references for more information.


© CS Dept Va Tech, 1997-1998.

All rights reserved.