Abstract: A short reference to the basics of HTML.
Since I teach a variety of people about HTML, I find it appropriate to keep
a simple reference to HTML handy, as much of the HTML documentation is
either unwieldy or outdated. For example, the HTML 3.0 documentation
runs over 190 pages, and the traditional HTML quick reference found
at http://kuhttp.cc.ukans.edu/lynx_help/HTML_quick.html still contains many
deprecated elements, such as <menu>. While I like
the Bare Bones Guide to HTML at
http://www.werbach.com/barebones,
I found that it is a little too terse for my students.
Unfortunately, my standard time pressures prevent me from making this a perfect document, and it is undoubtedly missing some of the components you might want to know about. Nonetheless, both my students and I find it of some use, particularly in the electronic form, and I hope you will, too.
In HTML, textual elements are traditionally surrounded by tags, although there are some tags that act as text elements. A piece of marked-up text looks something like
<TAG>some text</TAG>
In addition, certain tags may have attributes. For example, in NetScape's version of HTML, items in a list may indicate the type of mark that accompanies the item. In such cases, a piece of marked-up text looks something like
<TAG ATTRIBUTE_NAME=ATTRIBUTE>some text</TAG>
For example, one might indicate the title of a document with
<title>SamR's Quick HTML Reference</title>
Similarly, one might describe a table with a larger border with
<table border=10> ... </tabl>
Each HTML document is broken into two pieces:
As one might expect, the head is surrounded by <head> and
</head> tags, and the body is surrounded by
<body> and </body> tags. NetScape
extends the body tag with a background attribute. I
feel that this makes documents unreadable, but your mileage may vary.
In addition, the whole document should be surrounded by
<html> and </html> tags.
A basic HTML document might therefore appear as follows:
<html> <head> <title>A basic HTML document</title> </head> <body> This is the only line in the document. </body> </html>
<title>..</title> -- the
title of the document.
<link rev="made" href="mailto:...">
link tags, such as to previous and next document.
This section needs to be expanded. More in HTML 3.0 specs.
<base>..</base> -- the
base name of the document; used for relative addressing.
<meta ...> -- a meta command,
most frequently used to embed http commands. For example,
<meta http-equiv="Refresh" content="1; url=nifty.left.html"> tells the browser to switch to another document after 1 second.
<p>..</p> -- a paragraph.
Need not have the </p> tag, in which case
<p> is treated as a paragraph separator.
<p align="LEFT">..</p> -- a left-aligned
paragraph (the default)
<p align="CENTER">..</p> -- centered
paragraph
<p align="RIGHT">..</p> -- a right-aligned
paragraph
<blockquote>..</blockquote> -- a quoted piece of text. I recall seeing that this may disappear.
<address>..</address> -- the address of the document author
<pre>..</pre> -- preformatted text. Usually presented in a monospace font.
HTML uses a hierachical heading system, with labels from
<h1> to <h6> Much of the documentation
suggests that you only use them in order (that is, don't nest h5 in h3 without
an intervening h4).
<em>..</em> -- emphasized
text.
<strong>..</strong> --
more strongly emphasized text.
<code>..</code> --
program code.
<i>..</i> --
display text in italics. Not recommended..
<b>..</b> --
display text in boldface. Not recommended..
<tt>..</tt> --
display text in typewriter font.
In general, special characters in HTML have the form
&name;. There are more such
characters than I want to list. Some of the more common ones are
& -- an ampersand, &
< -- a less-than sign, <
> -- a greather-than sign, >
© -- a copyright symbol, ©
-- a "non-breaking space", useful when
you really need extra space at a particular point
<img src="URL">..</img> --
alt="text" -- include alternate text to use
if the image cannot be displayed
align={top,middle,bottom} -- align the image relative
to the text.
<hr> -- a horizontal rule,
useful for separating sections.
<a href="URL">..</a> -- a link to another
document.
<a name="text">..</a> -- a named section
of the present document.
<a href="#text">..</a> -- a link to a named
section in the current document.
<a href="URL#text">..</a> -- a link to a named
section in another document.
<ol>..</ol> --
an ordered list.
The elements of the list are numbered (or lettered or ...)
sequentially. NetScape extends this with various attributes.
<ul>..</ul> -- an
unordered list. The elements of the list are indicated with
some token. NetScape extends this with various attributes.
<li>..</li> -- an
element in an ordered or unordered list. NetScape extends this
with various attributes. The </li> is optional.
<dl>..</dl> -- a
definition list. Traditionally, a list of words and their
definitions. <dt>..</dt> -- the
definition term, the
object being defined.<dd>..</dd> -- the
definition.
<table>..</table> --
delineate the table.
border=# -- determine the size of the border drawn
around the table
cellspacing=# -- spacing between cells
cellpadding=# -- spacing between contents and
data
width=# or width=#% -- the width
of the table.
<tr>..</tr> -- a row
in a table.
align={left,center,right} -- align data in cells
valign={top,middle bottom,baseline} -- align data
in cells
<td>..</td> -- a data
cell in a row of the table.
align={left,center,right} -- align data in cells
valign={top,middle bottom,baseline} -- align data
in cells
nowrap -- don't wrap the contents of the cell
colspan=# -- make a cell span multiple columns
rowspan=# -- make a cell span multiple rows
<th>..</th> -- a cell
used as a column or row heading in the table.
Attributes are as for <td>.
<caption>..</caption>
align={top,bottom} -- does the caption appear
above or below the body of the table
Forms are normally used to provide data to a CGI program, such as a search engine. They may also be used for input and output for some programming languages, such as JavaScript.
<form options>...</form> -- A form
name="..." -- the name of the form
action="URL" -- the URL of the CGI program
method="..." (often get) -- how to
communicate with the CGI script.
<input type="text" options -- a text box
name="..." -- the name of the text box
(important this is used by most CGI scripts)
value="..." -- the default value in the text box
<input type="button" options -- a button
name="..." -- the name of the button
value="..." -- the text that appears in the button
<input type="submit" options -- a submit button, which submits the form
name="..." -- the name of the button
value="..." -- the text that appears in the button
<input type="hidden" --
a hidden field (mostly used to provide information to the server)
name="..." -- the name of the field
value="..." -- the value of the field
<input type="checkbox" --
a checkbox
name="..." -- the name of the checkbox
value="..." -- the value of the checkbox.
Note that this does not create visible text ... you
must add it manually.
<input type="radio" --
a radio button
name="..." -- the name of the radio button. All
buttons in a group should have the same name.
value="..." -- the text that appears by the radio button.
Note that this does not create visible text ... you
must add it manually.
<!-- ... --> -- a
comment to the reader of the HTML file. Usually not interpreted by
the browser.
<br> -- force a break.
<font>...</font> --
specify font information for text. In general, you shouldn't use
this, as it is almost purely physical.
<font size="#">...</font> -- set the
font size for some text
<font size="+#">...</font> -- increase the
font size for some text
<font size="-#">...</font> -- decrease the
font size for some text
<font color="...">...</font> -- set the
color for some text
<!-- ... --> (comment)
<a ...> (an anchor or link).
<address> (the address of the author of the document)
<b> (boldface text)
<base> (base of document)
<blockquote> (a quotation)
<body> (body of HTML document)
<br> (break)
<caption> (caption of table)
<caption> (short amounts of program code)
<dd> (definition)
<dl> (definition term)
<dt> (definition list)
<em> (emphasized text)
<font> (change appearance of text)
<form> (a form)
<head> (head of HTML document)
<html> (HTML document)
<input type="button">
(normal button in a form)
<input type="submit">
(submit button in a form)
<input type="text">
(text field in a form)
<i> (italicized text)
<html> (include an image)
<li> (item in a list)
<ul> (ordered/numbered list)
<p> (paragraph)
<pre> (preformatted text)
<strong> (emphasized text)
<table> (table)
<td> (table data)
<th> (table heading)
<title> (document title)
<tr> (table row)
<tt> (typewriter text)
<ul> (unordered/unnumbered list)
This page written by Samuel A. Rebelsky.
This page generated on 54 by SamR's Site Suite.