HTML Guide
An HTML document is a text file, written with any text editor, containing the document's subject. A series of formatting commands inserted into the text control the document's appearance. These formatting commands or tags tell the browser how to display the pages. Tags appear within angled brackets, most are used in pairs with a forward slash (/) indicating the final tag.
For example, the tag for emphasising text (which is usually rendered in italics) is <em>..</em>.
Applying this to the sentence "This is emphasis." requires the following HTML tags and text:
<em>This is emphasis.</em>- This is emphasis.
Four tags define the basic structure of a document:
<HTML>...</HTML> mark the beginning and end of the document.
<HEAD>...</HEAD> denote the header and usually contains
<TITLE>...</TITLE> tags. Text within these is displayed in the window's title bar.
<BODY>...</BODY> tags mark the main portion of the document that is
displayed to the user.
Here is an example of a basic HTML document:
<HTML>
<HEAD>
<TITLE>The Window Title</TITLE>
</HEAD>
<BODY>
Main document text
</BODY>
</HTML>
Headings
There are six sizes of heading text for formatting headings and sub-headings in a document.
Their respective tags are: <H1>..</H1>, <H2>..</H2>,
<H3>..</H3> etc.
Text Attributes
The two most commonly used text attributes are strong <strong>..</strong>, and emphasis
<em>..</em>.
<strong>This text is strong</strong>, <em>this is emphasis</em>- This text is strong, this is emphasis
Seperators
Browsers ignore line breaks and carriage returns in the HTML file. Text seperation is controlled by single tags, a closing tag is not required:
<P>..</P>Paragraph tag — each paragraph is seperated by one line of white space.<BR>Line break — no extra white space follows this tag.<HR>Horizontal rule — the browser draws a horizontal line across the screen and creates white space above and below the line.
Lists
Items in an unordered list are bulleted. The list is enclosed by <UL>..</UL> tags
and each list item in <LI>..</LI> tags.
| Example unordered list | |
|---|---|
<UL>
|
|
Ordered lists are numbered and specified by the tags
<OL>..</OL>.
| Example ordered list | |
|---|---|
<OL>
|
|
Descriptive lists are indented:
| Example descriptive list | |
|---|---|
<DL>
|
|
Anchors
An anchor specifies a clickable hypertext link. The link can be:
- A destination address (URL)
e.g.<A HREF="URL">..</A> - A destination file in the directory that the current document is stored in. The server looks in this directory to find the file.
e.g.
<A HREF="filename">...</A> - A point in the current HTML document:
Anchor<A NAME="name">links the point to the target<A HREF="#name">...</A>
Examples of Anchors
<A HREF="http://www.microsoft.com">Microsoft</A>creates a link to Microsoft.<A HREF="index.html"></A>links to my home page.<A NAME="#top">...</A>points to a target at the top of this page.
Graphics
An image file can be displayed in the document using inline graphic commands.
The file, usually in .GIF or .JPG format, is external and displayed in the document's text by the browser. The
image is inserted into the document by <IMG SRC="mypic.gif">
In the above example the file is in the same directory as the HTML file,
otherwise the path and filename are needed: </PICTURES/IMG SRC="mypic.gif">
An example of an inline image.
My cat Felix.
The <IMG> tag has various attributes that
control the way an image is displayed.
ALIGN: Surrounding text is aligned with the top, middle or bottom of the graphic e.g.<IMG SRC="mypic.gif" ALIGN=TOP>ALIGN: The graphic is displayed flush with the left or right hand margins. e.g.<IMG SRC="mypic.gif" ALIGN=RIGHT>. Text will display on the left of the graphicALT: Text is displayed instead of the picture if the Show Pictures option is turned off e.g.<IMG SRC="mypic.gif" ALT="My picture">BORDER: A border is drawn around the image. The border in invisible unless the image is a hypertext link, when the border is drawn in the hyperlink colour. Border size is specified in pixels<IMG SRC="mypic.gif" BORDER=5>HEIGHT & WIDTH: Specifies the height and width of the picture in pixels. The picture is stretched to fit if the actual dimensions differ from those specified.<IMG SRC="mypic.gif" HEIGHT=80 WIDTH=150>HSPACE & VSPACE: Specify, in pixels, the size of margins for an image.HSPACEleaves space on the left and right of the image andVSPACEspace top and bottom.<IMG SRC="mypic.gif" HSPACE=10 VSPACE=5>
Tables
A table has three main components rows, data cells and header cells. It is defined by
<TABLE>..</TABLE> tags which must enclose all other tags.
- Table rows : The number of rows is specified by the number of
<TR>..</TR>tags. - Table data:
A standard table data cell must only appear within table rows and is enclosed by
<TD>..</TD>. A cell can contain any of the tags that can be used in the body of a HTML document. - Table header: Defined by
<TH>..</TH>tags; header cells are rendered in a bold font.
Table Attributes
CAPTION: A table may have a caption, enclosed in<CAPTION>..</CAPTION>tags,ALIGNleft, right or centre;VALIGNtop or bottom.WIDTH: In pixels or a percentage of screen width. The width attribute is applied to tables and cells. e.g.WIDTH=30%,WIDTH=250.BORDER: A table can have a visible borderBORDER=1, or no borderBORDER=0.CELLPADDING: A table attribute in pixels,CELLPADDING=5CELLSPACING: A table attribute in pixels,CELLSPACING=5COLSPAN: Specifies the number of columns a cell should span (default is one) and can appear in any table cell; e.g.COLSPAN=2ROWSPAN: Specifies the number of rows a cell can span. Has a default of one; e.g.ROWSPAN=3BGCOLOR: Specifies background colours for tables and cells, e.g.BGCOLOR="GREEN", BGCOLOR="#00ff00"
Table Examples
| Table with border | |
|---|---|
| This is a cell 1 | This is cell 2 |
| Table without border | |
|---|---|
| This is a cell 1 | This is cell 2 |
| Cellpadding | |
|---|---|
| Cell 1 | Cell 2 |
| Cellspacing | |
|---|---|
| Cell 1 | Cell 2 |
Backgrounds
If a background is not specified in a HTML document the browser uses its own
default colour as a background to the document. This behaviour can be modifed by
attributes used in the opening <BODY> tag.
Generally there are two choices of background; a bitmap (usually a GIF or JPG file)
using the BACKGROUND attribute, or a plain colour
defined by the BGCOLOR attribute.
The bit map background is tiled by the browser so that it fills the browser window:
<BODY BACKGROUND="backpic.gif">
or a plain coloured background is set by the BGCOLOR attribute:
<BODY BGCOLOR="colour">
Where "colour" is either one of the sixteen named
system colours (red, blue, green etc.) or a hexadecimal number denoting the red-green-blue colour value, e.g.
<BODY BGCOLOR="#0000FF">
Colour
Colour in an HTML document is specified by the colour name (sixteen named colours are available) or colour value. Hexadecimal colour values range from #000000 (black) to #FFFFFF (white), with 216 colours available from a palette of 256 (40 are reserved).
If a page specifies a RGB colour that is not available from the 256 colour palette, the browser uses the closest match it can find. In practice colours are best specified from the hexadecimal pairs 00, 33, 66, 99, CC and FF, otherwise they may not display correctly on some systems.

Other Tags
Other common HTML tags include:
<!-..-> : Comment - A comment by
the author of the file, the text between the tags is ignored by the browser.