Search Engine Marketing Definitions![html coding HTML documents are plaintext (also known as ASCII) files that can be created using any text editor.
<H4 align=left><A name=TEM>Tags Explained</A></H4>
<P>An <I>element</I> is a fundamental component of the structure of a text
document. Some examples of elements are heads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file for your browser. Elements can contain plain text, other elements, or both. <P>To denote the various elements in an HTML document, you use <I>tags</I>. HTML tags consist of a left angle bracket (<TT><</TT>), a tag name, and a right angle bracket (<TT>></TT>). Tags are usually paired (e.g., <TT><H1></TT> and <TT></H1></TT>) to start and end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text within the brackets. HTML tags are <A href="#MT">listed below</A>. <P>Some elements may include an <I>attribute</I>, which is additional information that is included inside the start tag. For example, you can specify the alignment of images (top, middle, or bottom) by including the appropriate attribute with the image source HTML code. Tags that have optional attributes are <A href="#MT">noted below</A>. <P><B>NOTE:</B><I> HTML is not case sensitive. </I><TT><title></TT> is
equivalent to <TT><TITLE></TT> or <TT><TiTlE></TT>. There are a few exceptions noted in <A href="#ES">Escape Sequences</A> below.
<P>Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it will simply ignore it. Any text placed between a pair of unknown tags will still be displayed, however.
<H4 align=left><A name=TM2>The Minimal HTML Document</A></H4>
<P>Every HTML document should contain certain standard HTML tags. Each document consists of head and body text. The head contains the title, and the body contains the actual text that is made up of paragraphs, lists, and other elements. Browsers expect specific information because they are programmed according to HTML and SGML specifications.
<P>Required elements are shown in this sample barebones document:
<html> <head> <TITLE>A Simple HTML Example</TITLE> </head> <body> <H1>HTML is Easy To Learn</H1> <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph!</P> <P>And this is the second paragraph.</P> </body> </html>
<P>The required elements are the <TT><html></TT>, <TT><head></TT>,
<TT><title></TT>, and <TT><body></TT> tags (and their corresponding
end tags). Because you should include these tags in each file, you might want to
create a template file with them. (Some browsers will format your HTML file
correctly even if these tags are not included. But some browsers won't! So make
sure to include them.)</P>
<P>
<H2><A name=MT>Markup Tags</A></H2>
<P>
<H4 align=left><A name=HT>HTML</A></H4>
<P>This element tells your browser that the file contains HTML-coded
information. The file extension <TT>.html</TT> also indicates this an HTML
document and must be used. (If you are restricted to 8.3 filenames (e.g.,
<TT>LeeHome.htm</TT>, use only <TT>.htm</TT> for your extension.)
<H4 align=left><A name=HE2>HEAD</A></H4>
<P>The head element identifies the first part of your HTML-coded document that
contains the title. The title is shown as part of your browser's window (see
below).
<H4 align=left><A name=TI>TITLE</A></H4>
<P>The title element contains your document title and identifies its content in
a global context. The title is typically displayed in the title bar at the top
of the browser window, but not inside the window itself. The title is also what
is displayed on someone's hotlist or bookmark list, so choose something
descriptive, unique, and relatively short. A title is also used to identify your
page for search engines (such as <A href="http://www.hotbot.com/">HotBot</A> or
<A href="http://www.infoseek.com/">Infoseek</A>).
<P>For example, you might include a shortened title of a book along with the
chapter contents: <I>NCSA Mosaic Guide (Windows): Installation</I>. This tells
the software name, the platform, and the chapter contents, which is more useful
than simply calling the document <I>Installation</I>. Generally you should keep
your titles to 64 characters or fewer.
<H4 align=left><A name=BO>BODY</A></H4>
<P>The second--and largest--part of your HTML document is the body, which
contains the content of your document (displayed within the text area of your
browser window). The tags explained below are used within the body of your HTML
document.
<H4 align=left><A name=HE3>Headings</A></H4>
<P>HTML has six levels of headings, numbered 1 through 6, with 1 being the
largest. Headings are typically displayed in larger and/or bolder fonts than
normal body text. The first heading in each document should be tagged
<TT><H1></TT>.
<P>The syntax of the heading element is:
<BR><TT><H</TT><I>y</I><TT>></TT><I>Text of heading</I><TT>
</H</TT><I>y</I><TT>></TT> <BR>where <I>y</I> is a number between 1 and 6
specifying the level of the heading.
<P>Do not skip levels of headings in your document. For example, don't start
with a level-one heading (<H1>) and then next use a level-three
(<H3>) heading.
<H4 align=left><A name=PA>Paragraphs</A></H4>
<P>Unlike documents in most word processors, carriage returns in HTML files
aren't significant. In fact, any amount of <I>whitespace</I> -- including
spaces, linefeeds, and carriage returns -- are automatically compressed into a
single space when your HTML document is displayed in a browser. So you don't
have to worry about how long your lines of text are. Word wrapping can occur at
any point in your source file without affecting how the page will be displayed.
<P>In the barebones example shown in the Minimal HTML Document section, the
first paragraph is coded as
<p> <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph!</P>
</p>
<P>In the source file there is a line break between the sentences. A Web browser ignores this line break and starts a new paragraph only when it encounters another <TT><P></TT> tag.
<P><B>Important:</B> You must indicate paragraphs with <TT><P></TT>
elements. A browser ignores any indentations or blank lines in the source text.
Without <TT><P></TT> elements, the document becomes one large paragraph.
(One exception is text tagged as "preformatted," which is explained below.) For
example, the following would produce identical output as the first bare-bones
HTML example:
<p> <H1>Levelone heading</H1> <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph! </P> <P>And this is the second paragraph.</P></p>
<P>To preserve readability in HTML files, put headings on separate lines, use a
blank line or two where it helps identify the start of a new section, and
separate paragraphs with blank lines (in addition to the <TT><P></TT>
tags). These extra spaces will help you when you edit your files (but your
browser will ignore the extra spaces because it has its own set of rules on
spacing that do not depend on the spaces you put in your source file).</P>
<P><B>NOTE:</B> The <TT></P></TT> closing tag may be omitted. This is
because browsers understand that when they encounter a <TT><P></TT> tag,
it means that the previous paragraph has ended. However, since HTML now allows
certain attributes to be assigned to the <TT><P></TT> tag, it's generally
a good idea to include it.
<P>Using the <TT><P></TT> and <TT></P></TT> as a paragraph container
means that you can center a paragraph by including the
<TT>ALIGN=</TT><I>alignment</I> attribute in your source file. <p> <TT><P ALIGN=CENTER></TT> This is a centered paragraph. [See the formatted version below.] </P></p>
<P>
<P align=center>This is a centered paragraph.</P>
<P>It is also possible to align a paragraph to the right instead, by including
the <TT>ALIGN=RIGHT</TT> attribute. <TT>ALIGN=LEFT</TT> is the default
alignment; if no <TT>ALIGN</TT> attribute is included, the paragraph will be
leftaligned.
<H4 align=left><A name=LI>Lists</A></H4>
<P>HTML supports unnumbered, numbered, and definition lists. You can nest lists
too, but use this feature sparingly because too many nested items can get
difficult to follow.
<P><B>Unnumbered Lists</B>
<P>To make an unnumbered, bulleted list,
<OL>
<LI>start with an opening list <TT><UL></TT> (for unnumbered list) tag
<LI>enter the <TT><LI></TT> (list item) tag followed by the individual
item; no closing <TT></LI></TT> tag is needed
<LI>end the entire list with a closing list <TT></UL></TT> tag </LI></OL>
<P>Below is a sample threeitem list: <p> <UL> <LI> apples <LI> bananas <LI> grapefruit </UL></p>
<P>The output is:
<UL>
<LI>apples
<LI>bananas
<LI>grapefruit </LI></UL>
<P>The <TT><LI></TT> items can contain multiple paragraphs. Indicate the
paragraphs with the <TT><P></TT> paragraph tags.
<P><B>Numbered Lists</B>
<P>A numbered list (also called an <I>ordered list</I>, from which the tag name
derives) is identical to an unnumbered list, except it uses <TT><OL></TT>
instead of <TT><UL></TT>. The items are tagged using the same
<TT><LI></TT> tag. The following HTML code: <p> <OL> <LI> oranges <LI> peaches <LI> grapes </OL></p>
<P>produces this formatted output:
<OL>
<LI>oranges
<LI>peaches
<LI>grapes </LI></OL>
<P><B>Definition Lists</B>
<P>A definition list (coded as <TT><DL></TT>) usually consists of
alternating a <I>definition term</I> (coded as <TT><DT></TT>) and a
definition definition (coded as <TT><DD></TT>). Web browsers generally
format the definition on a new line and indent it.
<P>The following is an example of a definition list: <p> <DL> <DT> NCSA <DD> NCSA, the National Center for Supercomputing Applications, is located on the campus of the University of Illinois at Urbana-Champaign. <DT> Cornell Theory Center <DD> CTC is located on the campus of Cornell University in Ithaca, New York. </DL></p>
<P>The output looks like:
<DL>
<DT>NCSA
<DD>NCSA, the National Center for Supercomputing Applications, is located on the
campus of the University of Illinois at Urbana-Champaign.
<DT>Cornell Theory Center
<DD>CTC is located on the campus of Cornell University in Ithaca, New York.
</DD></DL>
<P>The <TT><DT></TT> and <TT><DD></TT> entries can contain multiple
paragraphs (indicated by <TT><P></TT> paragraph tags), lists, or other
definition information.
<P>The <TT>COMPACT</TT> attribute can be used routinely in case your definition
terms are very short. If, for example, you are showing some computer options,
the options may fit on the same line as the start of the definition. <p><DL COMPACT><DT> -i<DD>invokes NCSA Mosaic for Microsoft Windows using the initialization file defined in the path<DT> -k<DD>invokes NCSA Mosaic for Microsoft Windows in kiosk mode</DL></p>
<P>The output looks like:</P>
<DL>
<DT>-i
<DD>invokes NCSA Mosaic for Microsoft Windows using the initialization file
defined in the path.
<DT>-k
<DD>invokes NCSA Mosaic for Microsoft Windows in kiosk mode. </DD></DL>
<P><B>Nested Lists</B>
<P>Lists can be nested. You can also have a number of paragraphs, each
containing a nested list, in a single list item.
<P>Here is a sample nested list: <p> <UL> <LI> A few New England states: <UL> <LI> Vermont <LI> New Hampshire <LI> Maine </UL> <LI> Two Midwestern states: <UL> <LI> Michigan <LI> Indiana </UL> </UL></p>
<P>The nested list is displayed as
<UL>
<LI>A few New England states:
<UL>
<LI>Vermont
<LI>New Hampshire
<LI>Maine </LI></UL>
<LI>Two Midwestern states:
<UL>
<LI>Michigan
<LI>Indiana </LI></UL></LI></UL>
<H4 align=left><A name=PT>Preformatted Text</A></H4>
<P>Use the<TT><PRE></TT> tag (which stands for "preformatted") to generate
text in a fixedwidth font. This tag also makes spaces, new lines, and tabs
significant -- multiple spaces are displayed as multiple spaces, and lines break
in the same locations as in the source HTML file. This is useful for program
listings, among other things. For example, the following lines: <p> <PRE> #!/bin/csh cd $SCR cfs get mysrc.f:mycfsdir/mysrc.f cfs get myinfile:mycfsdir/myinfile fc -02 -o mya.out mysrc.f mya.out cfs save myoutfile:mycfsdir/myoutfile rm * </PRE></p>
<P>display as: <p> #!/bin/csh cd $SCR cfs get mysrc.f:mycfsdir/mysrc.f cfs get myinfile:mycfsdir/myinfile fc -02 -o mya.out mysrc.f mya.out cfs save myoutfile:mycfsdir/myoutfile rm *</p>
<P>The <TT><PRE></TT> tag can be used with an optional <TT>WIDTH</TT>
attribute that specifies the maximum number of characters for a line.
<TT>WIDTH</TT> also signals your browser to choose an appropriate font and
indentation for the text.
<P>Hyperlinks can be used within <TT><PRE></TT> sections. You should avoid
using other HTML tags within <TT><PRE></TT> sections, however.
<P>Note that because <, >, and & have special meanings in HTML, you
must use their escape sequences (<TT>&lt;</TT>, <TT>&gt;</TT>, and
<TT>&amp;</TT>, respectively) to enter these characters. See the section <A
href="#ES">Escape Sequences</A> for more information.
<H4 align=left><A name=EQ>Extended Quotations</A></H4>
<P>Use the <TT><BLOCKQUOTE></TT> tag to include lengthy quotations in a
separate block on the screen. Most browsers generally change the margins for the
quotation to separate it from surrounding text.
<P>In the example: <p> <P>Omit needless words.</P> <BLOCKQUOTE> <P>Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. </P> <P>--William Strunk, Jr., 1918 </P> </BLOCKQUOTE></p>
<P>the result is:
<P>Omit needless words.</P>
<BLOCKQUOTE>
<P>Vigorous writing is concise. A sentence should contain no unnecessary words,
a paragraph no unnecessary sentences, for the same reason that a drawing should
have no unnecessary lines and a machine no unnecessary parts.</P>
<P>--William Strunk, Jr., 1918</P></BLOCKQUOTE>
<H4 align=left><A name=FL>Forced Line Breaks/Postal Addresses</A></H4>
<P>
<P>The <TT><BR></TT> tag forces a line break with no extra (white) space
between lines. Using <TT><P></TT> elements for short lines of text such as
postal addresses results in unwanted additional white space. For example, with
<BR>: <p> National Center for Supercomputing Applications<BR> 605 East Springfield Avenue<BR> Champaign, Illinois 61820-5518<BR></p>
<P>The output is:</P>
<P>National Center for Supercomputing Applications<BR>605 East Springfield
Avenue<BR>Champaign, Illinois 61820-5518<BR>
<P>
<H4 align=left><A name=HR>Horizontal Rules</A></H4>
<P>The <TT><HR></TT> tag produces a horizontal line the width of the
browser window. A horizontal rule is useful to separate major sections of your
document.
<P>You can vary a rule's size (thickness) and width (the percentage of the
window covered by the rule). Experiment with the settings until you are
satisfied with the presentation. For example: <p><HR SIZE=4 WIDTH="50%"></p>
<P>displays as:</P>
<HR width="50%" SIZE=4>
<P>
<H2><A name=CF>Character Formatting</A></H2>
<P>HTML has two types of styles for individual words or sentences: logical and
physical. <EM>Logical styles</EM> tag text according to its meaning, while
<I>physical styles</I> indicate the specific appearance of a section. For
example, in the preceding sentence, the words "logical styles" was tagged as
"emphasis." The same effect (formatting those words in italics) could have been
achieved via a different tag that tells your browser to "put these words in
italics."
<P>
<H4 align=left><A name=PV>Logical Versus Physical Styles</A></H4>
<P>
<P>If physical and logical styles produce the same result on the screen, why are
there both?
<P>In the ideal SGML universe, content is divorced from presentation. Thus SGML
tags a level-one heading as a level-one heading, but does not specify that the
level-one heading should be, for instance, 24-point bold Times centered. The
advantage of this approach (it's similar in concept to style sheets in many word
processors) is that if you decide to change level-one headings to be 20-point
left-justified Helvetica, all you have to do is change the definition of the
level-one heading in your Web browser. Indeed, many browsers today let you
define how you want the various HTML tags rendered on-screen using what are
called <I>cascading style sheets</I>, or CSS. CSS is more advanced than HTML,
though, and will not be covered in this Primer. (You can learn more about CSS at
the <A href="http://www.w3c.org/Style/">World Wide Web Consortium</A> CSS site.)
<P>Another advantage of logical tags is that they help enforce consistency in
your documents. It's easier to tag something as <TT><H1></TT> than to
remember that levelone headings are 24-point bold Times centered or whatever.
For example, consider the <TT><STRONG></TT> tag. Most browsers render it
in bold text. However, it is possible that a reader would prefer that these
sections be displayed in red instead. (This is possible using a local cascading
style sheet on the reader's own computer.) Logical styles offer this
flexibility.
<P>Of course, if you want something to be displayed in italics (for example) and
do not want a browser's setting to display it differently, you should use
physical styles. Physical styles, therefore, offer consistency in that something
you tag a certain way will always be displayed that way for readers of your
document.
<P>Try to be consistent about which type of style you use. If you tag with
physical styles, do so throughout a document. If you use logical styles, stick
with them within a document. Keep in mind that future releases of HTML might not
support certain logical styles, which could mean that browsers will not display
your logical-style coding. (For example, the <TT><DFN></TT> tag -- short
for "definition", and typically displayed in italics -- is not widely supported
and will be ignored if the reader's browser does not understand it.)
<H4 align=left>Logical Styles</H4>
<P>
<DL>
<DT><TT><DFN></TT>
<DD>for a word being defined. Typically displayed in italics. (<DFN>NCSA
Mosaic</DFN> is a World Wide Web browser.)
<DT><TT><EM></TT>
<DD>for emphasis. Typically displayed in italics. (<EM>Consultants cannot reset
your password unless you call the help line.</EM>)
<DT><TT><CITE></TT>
<DD>for titles of books, films, etc. Typically displayed in italics. (<CITE>A
Beginner's Guide to HTML</CITE>)
<DT><TT><CODE></TT>
<DD>for computer code. Displayed in a fixed-width font. (The
<TT><stdio.h></TT> header file)
<DT><TT><KBD></TT>
<DD>for user keyboard entry. Typically displayed in plain fixed-width font.
(Enter <KBD>passwd</KBD> to change your password.)
<DT><TT><SAMP></TT>
<DD>for a sequence of literal characters. Displayed in a fixed-width font.
(<SAMP>Segmentation fault: Core dumped.</SAMP>)
<DT><TT><STRONG></TT>
<DD>for strong emphasis. Typically displayed in bold. (<STRONG>NOTE:</STRONG>
Always check your links.)
<DT><TT><VAR></TT>
<DD>for a variable, where you will replace the variable with specific
information. Typically displayed in italics. (<KBD>rm</KBD> <VAR>filename</VAR>
deletes the file.) </DD></DL>
<H4 align=left>Physical Styles</H4>
<P>
<DL>
<DT><TT><B></TT>
<DD>bold text
<DT><TT><I></TT>
<DD>italic text
<DT><TT><TT></TT>
<DD>typewriter text, e.g. fixed-width font. </DD></DL>
<H4 align=left><A name=ES>Escape Sequences</A> (a.k.a. Character Entities)</H4>
<P>Character entities have two functions:
<UL>
<LI>escaping special characters
<LI>displaying other characters not available in the plain ASCII character set
(primarily characters with diacritical marks) </LI></UL>
<P>Three ASCII characters--the left angle bracket (<), the right angle
bracket (>), and the ampersand (&)--have special meanings in HTML and
therefore cannot be used "as is" in text. (The angle brackets are used to
indicate the beginning and end of HTML tags, and the ampersand is used to
indicate the beginning of an escape sequence.) Double quote marks may be used
as-is but a character entity may also be used (").</P>
<P>To use one of the three characters in an HTML document, you must enter its
<I>escape sequence</I> instead:
<DL>
<DT><TT>&lt;</TT>
<DD>the escape sequence for <
<DT><TT>&gt;</TT>
<DD>the escape sequence for >
<DT><TT>&amp;</TT>
<DD>the escape sequence for & </DD></DL>
<P>Additional escape sequences support accented characters, such as:
<DL>
<DT><TT>&ouml;</TT>
<DD>a lowercase o with an umlaut: ö
<DT><TT>&ntilde;</TT>
<DD>a lowercase n with a tilde: ñ
<DT><TT>&Egrave;</TT>
<DD>an uppercase E with a grave accent: È </DD></DL>
<P>You can substitute other letters for the <I>o</I>, <I>n</I>, and <I>E</I>
shown above. Visit the World Wide Web Consortium for a complete list of <A
href="http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_13.html#SEC106">special
characters</A>.</P>
<P><B>NOTE:</B> Unlike the rest of HTML, the escape sequences are case
sensitive. You cannot, for instance, use <TT>&LT;</TT> instead of
<TT>&lt;</TT>.
<P>
<H2><A name=LI2>Linking</A></H2>
<P>The chief power of HTML comes from its ability to link text and/or an image
to another document or section of a document. A browser highlights the
identified text or image with color and/or underlines to indicate that it is a
<I>hypertext link</I> (often shortened to <I>hyperlink</I> or just <I>link</I>).
<P>HTML's single hypertextrelated tag is <TT><A></TT>, which stands for
<I>anchor</I>. To include an anchor in your document:
<OL>
<LI>start the anchor with <TT><A</TT> (include a space after the <TT>A</TT>)
<LI>specify the document you're linking to by entering the parameter
<TT>HREF="</TT><I>filename</I><TT>"</TT> followed by a closing right angle
bracket (<TT>></TT>)
<LI>enter the text that will serve as the hypertext link in the current document
<LI>enter the ending anchor tag: <TT></A></TT> (no space is needed before
the end anchor tag) </LI></OL>
<P>Here is a sample hypertext reference in a file called <TT>US.html</TT>: <p> <A HREF="MaineStats.html">Maine</A></p>
<P>This entry makes the word <I>Maine</I> the hyperlink to the document
<TT>MaineStats.html</TT>, which is in the same directory as the first document.
<H4 align=left><A name=RL>Relative Pathnames Versus Absolute Pathnames</A></H4>
<P>You can link to documents in other directories by specifying the <I>relative
path</I> from the current document to the linked document. For example, a link
to a file <TT>NYStats.html</TT> located in the subdirectory
<TT>AtlanticStates</TT> would be: <p> <A HREF="AtlanticStates/NYStats.html">New York</A></p>
<P>These are called <I>relative links</I> because you are specifying the path to
the linked file relative to the location of the current file. You can also use
the absolute pathname (the complete URL) of the file, but relative links are
more efficient in accessing a server. They also have the advantage of making
your documents more "portable" -- for instance, you can create several web pages
in a single folder on your local computer, using relative links to hyperlink one
page to another, and then upload the entire folder of web pages to your web
server. The pages on the server will then link to other pages on the server, and
the copies on your hard drive will still point to the other pages stored there.
<P>It is important to point out that UNIX is a casesensitive operating system
where filenames are concerned, while DOS and the MacOS are not. For instance, on
a Macintosh, "DOCUMENT.HTML", "Document.HTML", and "document.html" are all the
same name. If you make a relative hyperlink to "DOCUMENT.HTML", and the file is
actually named "document.html", the link will still be valid. But if you upload
all your pages to a UNIX web server, the link will no longer work. Be sure to
check your filenames before uploading.
<P>Pathnames use the standard UNIX syntax. The UNIX syntax for the parent
directory (the directory that contains the current directory) is "..". (For more
information consult a beginning UNIX reference text such as <I>Learning the UNIX
Operating System</I> from O'Reilly and Associates, Inc.)
<P>If you were in the <TT>NYStats.html</TT> file and were referring to the
original document <TT>US.html</TT>, your link would look like this: <p> <A HREF="../US.html">United States</A></p>
<P>In general, you should use relative links whenever possible because:</P>
<OL>
<LI>it's easier to move a group of documents to another location (because the
relative path names will still be valid)
<LI>it's more efficient connecting to the server
<LI>there is less to type </LI></OL>
<P>However, use absolute pathnames when linking to documents that are not
directly related. For example, consider a group of documents that comprise a
user manual. Links within this group should be relative links. Links to other
documents (perhaps a reference to related software) should use absolute
pathnames instead. This way if you move the user manual to a different
directory, none of the links would have to be updated.
<H4 align=left><A name=UR>URLs</A></H4>
<P>The World Wide Web uses Uniform Resource Locators (URLs) to specify the
location of files on other servers. A URL includes the type of resource being
accessed (e.g., Web, gopher, FTP), the address of the server, and the location
of the file. The syntax is:
<P><I>scheme</I><TT>://</TT><I>host.domain</I>
<TT>[:</TT><I>port</I><TT>]/</TT><I>path</I><TT>/</TT> <I>filename</I>
<P>where <I>scheme</I> is one of
<DL>
<DT><TT>file</TT>
<DD>a file on your local system
<DT><TT>ftp</TT>
<DD>a file on an anonymous FTP server
<DT><TT>http</TT>
<DD>a file on a World Wide Web server
<DT><TT>gopher</TT>
<DD>a file on a Gopher server
<DT><TT>WAIS</TT>
<DD>a file on a WAIS server
<DT><TT>news</TT>
<DD>a Usenet newsgroup
<DT><TT>telnet</TT>
<DD>a connection to a Telnetbased service </DD></DL>
<P>The <I>port</I> number can generally be omitted. (That means unless someone
tells you otherwise, leave it out.)
<P>For example, to include a link to this primer in your document, enter: <p><A HREF="http://www.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimer.html">NCSA's Beginner's Guide to HTML</A></p>
<P>This entry makes the text <I>NCSA's Beginner's Guide to HTML</I> a hyperlink
to this document.
<P>There is also a <TT>mailto</TT> scheme, used to hyperlink email addresses,
but this scheme is unique in that it uses only a colon (<TT>:</TT>) instead of
<TT>://</TT> between the scheme and the address. You can read more about
<TT>mailto</TT> <A href="#M2">below</A>.
<P>For more information on URLs, refer to:
<UL>
<LI><A href="http://www.w3.org/hypertext/WWW/Addressing/Addressing.html"><I>WWW
Names and Addresses, URIs, URLs, URNs</I></A>
<LI><A href="/demoweb/url-primer.html"><I>A Beginner's Guide to URLs</I></A>
</LI></UL>
<H4 align=left><A name=LTS>Links to Specific Sections</A></H4>
<P>Anchors can also be used to move a reader to a <I>particular section</I> in a
document (either the same or a different document) rather than to the top, which
is the default. This type of an anchor is commonly called a <I>named anchor</I>
because to create the links, you insert HTML names within the document.
<P>This guide is a good example of using named anchors in one document. The
guide is constructed as one document to make printing easier. But as one (long)
document, it can be time-consuming to move through when all you really want to
know about is one bit of information about HTML. Internal hyperlinks are used to
create a "table of contents" at the top of this document. These hyperlinks move
you from one location in the document to another location in the same document.
(Go to the <A href="#top">top</A> of this document and then click on the
<I>Links to Specific Sections</I> hyperlink in the table of contents. You will
wind up back here.)
<P>You can also link to a specific section in another document. That information
is presented first because understanding that helps you understand linking
within one document.
<H4 align=left>Links Between Sections of Different Documents</H4>
<P>Suppose you want to set a link from document A (<TT>documentA.html</TT>) to a
specific section in another document (<TT>MaineStats.html</TT>).
<P>Enter the HTML coding for a link to a named anchor: <p> <TT>documentA.html</TT>: In addition to the many state parks, Maine is also home to <a href="MaineStats.html#ANP">Acadia National Park</a>.</p>
<P>Think of the characters after the hash (#) mark as a tab within the
<TT>MaineStats.html</TT> file. This tab tells your browser what should be
displayed at the top of the window when the link is activated. In other words,
the first line in your browser window should be the Acadia National Park
heading.</P>
<P>Next, create the <I>named anchor</I> (in this example "ANP") in
<TT>MaineStats.html</TT>: <p> <H2><A NAME="ANP">Acadia National Park</a></H2> </p>
<P>With both of these elements in place, you can bring a reader directly to the
Acadia reference in <TT>MaineStats.html</TT>.</P>
<P><B>NOTE:</B> You cannot make links to specific sections within a different
document unless either you have write permission to the coded source of that
document or that document already contains indocument named anchors. For
example, you could include named anchors to this primer in a document you are
writing because there are named anchors in this guide (use View Source in your
browser to see the coding). But if this document did <I>not</I> have named
anchors, you could not make a link to a specific section because you cannot edit
the original file on NCSA's server.
<H4 align=left>Links to Specific Sections within the Current Document</H4>
<P>The technique is the same except the filename is <I>omitted</I>.
<P>For example, to link to the <TT>ANP</TT> anchor from within
<TT>MaineStats</TT>, enter: <p> ...More information about <A HREF="#ANP">Acadia National Park</a> is available elsewhere in this document. </p>
<P>Be sure to include the <TT><A NAME=></TT> tag at the place in your
document where you want the link to jump to (<TT><A NAME="ANP">Acadia
National Park</a></TT>).</P>
<P>Named anchors are particularly useful when you think readers will print a
document in its entirety or when you have a lot of short information you want to
place online in one file.
<H4 align=left><A name=M2>Mailto</A></H4>
<P>
<P>You can make it easy for a reader to send electronic mail to a specific
person or mail alias by including the <TT>mailto</TT> attribute in a hyperlink.
The format is: <p><A HREF="mailto:<I>emailinfo@host</I>"><I>Name</I></a></p>
<P>For example, enter:</P><p> <A HREF="mailto:<I>pubs@ncsa.uiuc.edu</I>"> <I>NCSA Publications Group</I></a></p>
<P>to create a mail window that is already configured to open a mail window for
the <A href="mailto:pubs@ncsa.uiuc.edu">NCSA Publications Group</A> alias. (You,
of course, will enter another mail address!)</P>
<P>
<H2><A name=II>Inline Images</A></H2>
<P>Most Web browsers can display inline images (that is, images next to text)
that are in X Bitmap (XBM), GIF, or JPEG format. Other image formats are also
being incorporated into Web browsers [e.g., the Portable Network Graphic (PNG)
format]. Each image takes additional time to download and slows down the initial
display of a document. Carefully select your images and the number of images in
a document.
<P>To include an inline image, enter: <p> <IMG SRC=<I>ImageName</I>></p>
<P>where <I>ImageName</I> is the URL of the image file.
<P>The syntax for <TT><IMG SRC></TT> URLs is identical to that used in an
anchor <TT>HREF</TT>. If the image file is a GIF file, then the filename part of
<I>ImageName</I> must end with <TT>.gif</TT>. Filenames of X Bitmap images must
end with <TT>.xbm</TT>; JPEG image files must end with <TT>.jpg</TT> or
<TT>.jpeg</TT>; and Portable Network Graphic files must end with <TT>.png</TT>.
<H4 align=left><A name=IS>Image Size Attributes</A></H4>
<P>You should include two other attributes on <TT><IMG></TT> tags to tell
your browser the size of the images it is downloading with the text. The
<TT>HEIGHT</TT> and <TT>WIDTH</TT> attributes let your browser set aside the
appropriate space (in pixels) for the images as it downloads the rest of the
file. (You can get the pixel size from your image-processing software, such as
Adobe Photoshop. Some browsers will also display the dimensions of an image file
in the title bar if the image is viewed by itself without an enclosing HTML
document.)
<P>For example, to include a self portrait image in a file along with the
portrait's dimensions, enter: <p> <IMG SRC=SelfPortrait.gif HEIGHT=100 WIDTH=65></p>
<P><B>NOTE:</B> Some browsers use the <TT>HEIGHT</TT> and <TT>WIDTH</TT>
attributes to stretch or shrink an image to fit into the allotted space when the
image does not exactly match the attribute numbers. Not all browser developers
think stretching/shrinking is a good idea, so don't plan on your readers having
access to this feature. Check your dimensions and use the correct ones.
<H4 align=left><A name=AI>Aligning Images</A></H4>
<P>You have some flexibility when displaying images. You can have images
separated from text and aligned to the left or right or centered. Or you can
have an image aligned with text. Try several possibilities to see how your
information looks best.
<P><B>Aligning Text with an Image</B><BR>By default the bottom of an image is
aligned with the following text, as shown in this paragraph. You can align
images to the top or center of a paragraph using the <TT>ALIGN=</TT> attributes
<TT>TOP</TT> and <TT>CENTER</TT>.
<P>This text is aligned with the top of the image (<TT><IMG SRC =
"BarHotlist.gif" ALT="[HOTLIST]" ALIGN=TOP></TT>). Notice how the browser
aligns only one line and then jumps to the bottom of the image for the rest of
the text.
<P>And this text is centered on the image (<TT><IMG SRC = "BarHotlist.gif"
ALT="[HOTLIST]" ALIGN=CENTER></TT>). Again, only one line of text is
centered; the rest is below the image.
<P>
<P><B>Images without Text</B> <BR>To display an image without any associated
text (e.g., your organization's logo), make it a separate paragraph. Use the
paragraph <TT>ALIGN=</TT> attribute to center the image or adjust it to the
right side of the window as shown below: <p><p ALIGN=CENTER><IMG SRC = "BarHotlist.gif" ALT="[HOTLIST]"></p></p>
<P>which results in:</P>
<P align=center></P>
<P>The image is centered; this paragraph starts below it and left justified.</P>
<P>
<H4 align=left><A name=AT2>Alternate Text for Images</A></H4>
<P>
<P>Some World Wide Web browsers -- primarily the textonly browsers such as <A
href="http://lynx.browser.org/">Lynx</A> -- cannot display images. Some users
turn off image loading even if their software can display images (especially if
they are using a modem or have a slow connection). HTML provides a mechanism to
tell readers what they are missing on your pages if they can't load images.
<P>The <TT>ALT</TT> attribute lets you specify text to be displayed instead of
an image. For example: <p> <IMG SRC="UpArrow.gif" ALT="Up"></p>
<P>where <TT>UpArrow.gif </TT>is the picture of an upward pointing arrow. With
graphics-capable viewers that have image-loading turned on, you see the up arrow
graphic. With a text-only browser or if image-loading is turned off, the word
<I>Up</I> is shown in your window in place of the image.
<P>You should try to include alternate text for each image you use in your
document, which is a courtesy for your readers -- or, for users who might be
visually impaired, a necessity.
<H4 align=left><A name=IH>Images as Hyperlinks</A></H4>
<P>Inline images can be used as hyperlinks just like plain text. The following
HTML code: <p> <A HREF="hotlist.html"><IMG SRC="BarHotlist.gif" ALT="[HOTLIST]"></A></p>
<P>Produces the following result:
<P><A href="hotlist.html"></A>
<P>(Note that this link doesn't actually go anywhere.) The blue border that
surrounds the image indicates that it's a clickable hyperlink. You may not
always want this border to be displayed, though. In this case you can use the
BORDER attribute of the IMG tag to make the image appear as normal. Adding the
BORDER attribute and setting it to zero: <p> <A HREF="hotlist.html"><IMG SRC="BarHotlist.gif" BORDER=0 ALT="[HOTLIST]"></A></p>
<P>Produces the following result:
<P><A href="hotlist.html"></A>
<P>The BORDER attribute can also be set to nonzero values, whether or not the
image is used as a hyperlink. In this case, the border will appear using the
default text color for the web page. For instance, if you wanted to give your
image a plain black border to help it stand out on the page, you might try this:
<p> <IMG SRC="BarHotlist.gif" BORDER=6 ALT="[HOTLIST]"></p>
<P>And get the following result:
<P>
<H4 align=left><A name=BG>Background Graphics</A></H4>
<P>Newer versions of Web browsers can load an image and use it as a background
when displaying a page. Some people like background images and some don't. In
general, if you want to include a background, make sure your text can be read
easily when displayed on top of the image.
<P>Background images can be a texture (linen finished paper, for example) or an
image of an object (a logo possibly). You create the background image as you do
any image.
<P>However you only have to create a small piece of the image. Using a feature
called tiling, a browser takes the image and repeats it across and down to fill
your browser window. In sum you generate one image, and the browser replicates
it enough times to fill your window. This action is automatic when you use the
background tag shown below.
<P>The tag to include a background image is included in the
<TT><BODY></TT> statement as an attribute: <p><BODY BACKGROUND="<I>filename</I>.gif"></p>
<H4 align=left><A name=OC>Background Color</A></H4>
<P>By default browsers display text in black on a gray background. However, you
can change both elements if you want. Some HTML authors select a background
color and coordinate it with a change in the color of the text.
<P>Always preview changes like this to make sure your pages are readable. (For
example, many people find red text on a black background difficult to read!) In
general, try to avoid using high-contrast images or images that use the color of
your text anywhere within the graphic.
<P>You change the color of text, links, visited links, and active links (links
that are currently being clicked on) using further attributes of the
<TT><BODY></TT> tag. For example: <p><BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#9690CC"></p>
<P>This creates a window with a black background (<TT>BGCOLOR</TT>), white text
(<TT>TEXT</TT>), and silvery hyperlinks (<TT>LINK</TT>).</P>
<P>The sixdigit number and letter combinations represent colors by giving their
RGB (red, green, blue) value. The six digits are actually three two-digit
numbers in sequence, representing the amount of red, green, or blue as a
hexadecimal value in the range 00-FF. For example, 000000 is black (no color at
all), FF0000 is bright red, 0000FF is bright blue, and FFFFFF is white (fully
saturated with all three colors).
<P>These number and letter combinations are generally rather cryptic.
Fortunately an online resource is available to help you track down the
combinations that map to specific colors and there is software available for you
to do this on your workstation:
<UL>
<LI><A href="http://www.visibone.com/colorlab/">VisiBone Online Color Lab for
the Webmaster's Palette</A><BR></LI></UL>
<P>For some basic colors -- typically those in the standard sixteencolor Windows
3.1 palette -- you can also use the name of the color instead of the
corresponding RGB value. For example, "black", "red", "blue", and "cyan" are all
valid for use in place of RGB values. However, while not all browsers will
understand all color names, any browser that can display colors will understand
RGB values, so use them whenever possible.
<H4 align=left><A name=EI>External Images, Sounds, and Animations</A></H4>
<P>You may want to have an image open as a separate document when a user
activates a link on either a word or a smaller, inline version of the image
included in your document. This is called an external image, and it is useful if
you do not wish to slow down the loading of the main document with large inline
images.
<P>To include a reference to an external image, enter: <p> <A HREF="<I>MyImage.gif</I>">link anchor</A></p>
<P>You can also use a smaller image as a link to a larger image. Enter:</P><p> <A HREF="<I>LargerImage.gif</I>"><IMG SRC="<I>SmallImage.gif</I>"></A></p>
<P>The reader sees the <TT>SmallImage.gif</TT> image and clicks on it to open
the <TT>LargerImage.gif</TT> file.</P>
<P>Use the same syntax for links to external animations and sounds. The only
difference is the file extension of the linked file. For example,
<P><TT><A HREF="AdamsRib.mov">link anchor</A></TT>
<P>specifies a link to a QuickTime movie. Some common file types and their
extensions are:
<P>
<DL>
<DT>plain text
<DD><TT>.txt</TT>
<DT>HTML document
<DD><TT>.html</TT>
<DT>GIF image
<DD><TT>.gif</TT>
<DT>TIFF image
<DD><TT>.tiff</TT>
<DT>X Bitmap image
<DD><TT>.xbm</TT>
<DT>JPEG image
<DD><TT>.jpg</TT> or <TT>.jpeg</TT>
<DT>PostScript file
<DD><TT>.ps</TT>
<DT>AIFF sound file
<DD><TT>.aiff</TT>
<DT>AU sound file
<DD><TT>.au</TT>
<DT>WAV sound file
<DD><TT>.wav</TT>
<DT>QuickTime movie
<DD><TT>.mov</TT>
<DT>MPEG movie
<DD><TT>.mpeg</TT> or <TT>.mpg</TT> </DD></DL>
<P>Keep in mind your intended audience and their access to software. Most UNIX
workstations, for instance, cannot view QuickTime movies.
<P>
<H2><A name=TA>Tables</A></H2>
<P>Before HTML tags for tables were finalized, authors had to carefully format
their tabular information within <TT><PRE></TT> tags, counting spaces and
previewing their output. Tables are very useful for presentation of tabular
information as well as a boon to creative HTML authors who use the table tags to
present their regular Web pages. (Check out the <A
href="http://www.ncsa.uiuc.edu/">NCSA home page</A> for an excellent example of
using tables to control page layout.)
<P>Think of your tabular information in light of the coding explained below. A
table has heads where you explain what the columns/rows include, rows for
information, cells for each item. In the following table, the first column
contains the header information, each row explains an HTML table tag, and each
cell contains a paired tag or an explanation of the tag's function.</P>
<P>
<TABLE width=450 border=1>
<TBODY>
<TR>
<TH colSpan=2>
<H4 align=left><A name=TT>Table Elements</A></H4><BR></TH></TR>
<TR>
<TH>Element</TH>
<TH>Description</TH></TR>
<TR vAlign=top>
<TD><TT><TABLE></TT> ... <TT></TABLE></TT></TD>
<TD>defines a table in HTML. If the <TT>BORDER</TT> attribute is present, your
browser displays the table with a border. </TD></TR>
<TR vAlign=top>
<TD><TT><CAPTION></TT> ... <TT></CAPTION></TT></TD>
<TD>defines the caption for the title of the table. The default position of the
title is centered at the top of the table. The attribute <TT>ALIGN=BOTTOM</TT>
can be used to position the caption below the table. <BR><B>NOTE:</B> Any kind
of markup tag can be used in the caption. </TD></TR>
<TR vAlign=top>
<TD><TT><TR></TT> ... <TT></TR></TT></TD>
<TD>specifies a table row within a table. You may define default attributes for
the entire row: <TT>ALIGN</TT> (<TT>LEFT</TT>, <TT>CENTER</TT>, <TT>RIGHT</TT>)
and/or <TT>VALIGN</TT> (<TT>TOP</TT>, <TT>MIDDLE</TT>, <TT>BOTTOM</TT>). See
Table Attributes at the end of this table for more information. </TD></TR>
<TR vAlign=top>
<TD><TT><TH></TT> ... <TT></TH></TT></TD>
<TD>defines a table header cell. By default the text in this cell is bold and
centered. Table header cells may contain other attributes to determine the
characteristics of the cell and/or its contents. See Table Attributes at the end
of this table for more information. </TD></TR>
<TR vAlign=top>
<TD><TT><TD></TT> ... <TT></TD></TT></TD>
<TD>defines a table data cell. By default the text in this cell is aligned left
and centered vertically. Table data cells may contain other attributes to
determine the characteristics of the cell and/or its contents. See Table
Attributes at the end of this table for more information.
</TD></TR></TBODY></TABLE>
<TABLE width=450 border=1>
<TBODY>
<TR>
<TH colSpan=2>
<H4 align=left><A name=TT>Table Attributes</A></H4></TH></TR>
<TR>
<TD align=left colSpan=2><B>NOTE:</B> Attributes defined within
<TT><TH></TT> ... <TT></TH></TT> or <TT><TD></TT> ...
<TT></TD></TT> cells override the default alignment set in a
<TT><TR></TT> ... <TT></TR></TT>. </TD></TR>
<TR>
<TH>Attribute </TH>
<TH>Description </TH></TR>
<TR vAlign=top>
<TD><TT>ALIGN (LEFT, CENTER, RIGHT)</TT> </TD>
<TD>Horizontal alignment of a cell. </TD></TR>
<TR vAlign=top>
<TD><TT>VALIGN (TOP, MIDDLE, BOTTOM)</TT> </TD>
<TD>Vertical alignment of a cell. </TD></TR>
<TR vAlign=top>
<TD><TT>COLSPAN=</TT><I>n</I> </TD>
<TD>The number (<I>n</I>) of columns a cell spans. </TD></TR>
<TR vAlign=top>
<TD><TT>ROWSPAN=</TT><I>n</I> </TD>
<TD>The number (<I>n</I>) of rows a cell spans. </TD></TR>
<TR vAlign=top>
<TD><TT>NOWRAP</TT> </TD>
<TD>Turn off word wrapping within a cell. </TD></TR></TBODY></TABLE></P>
<H4 align=left><A name=GT>General Table Format</A></H4>
<P>The general format of a table looks like this: <p><TABLE><I><!-- start of table definition --></I><CAPTION> caption contents </CAPTION> <I><!-- caption definition --></I><TR> <I><!-- start of header row definition --></I> <TH> first header cell contents </TH> <TH> last header cell contents </TH> </TR> <I><!-- end of header row definition --></I><TR> <I><!-- start of first row definition --></I> <TD> first row, first cell contents </TD> <TD> first row, last cell contents </TD> </TR> <I><!-- end of first row definition --></I><TR> <I><!-- start of last row definition --></I> <TD> last row, first cell contents </TD> <TD> last row, last cell contents </TD> </TR> <I><!-- end of last row definition --></I></TABLE><I><!-- end of table definition --></I></p>
<P>You can cutandpaste the above code into your own HTML documents, adding new
rows or cells as necessary. The above example looks like <A
href="GenTableFormat.html">this</A> when rendered in a browser.
<P>The <TT><TABLE></TT> and <TT></TABLE></TT> tags <B>must</B>
surround the entire table definition. The first item inside the table is the
<TT>CAPTION</TT>, which is optional. Then you can have any number of rows
defined by the <TT><TR></TT> and <TT></TR></TT> tags. Within a row
you can have any number of cells defined by the
<TT><TD></TT>...<TT></TD></TT> or
<TT><TH></TT>...<TT></TH></TT> tags. Each row of a table is,
essentially, formatted independently of the rows above and below it. This lets
you easily display tables like the one above with a single cell, such as Table
Attributes, spanning columns of the table.
<H4 align=left><A name=TF>Tables for Nontabular Information</A></H4>
<P>Some HTML authors use tables to present nontabular information. For example,
because links can be included in table cells, some authors use a table with no
borders to create "one" image from separate images. Browsers that can display
tables properly show the various images seamlessly, making the created image
seem like an <I>image map</I> (one image with hyperlinked quadrants).
<P>Using table borders with images can create an impressive display as well.
Experiment and see what you like.
<P>
<H2><A name=FF>Fillout Forms</A></H2>
<P>Web forms let a reader return information to a Web server for some action.
For example, suppose you collect names and email addresses so you can email some
information to people who request it. For each person who enters his or her name
and address, you need some information to be sent and the respondent's
particulars added to a data base.
<P>This processing of incoming data is usually handled by a script or program
written in Perl or another language that manipulates text, files, and
information. If you cannot write a program or script for your incoming
information, you need to find someone who can do this for you.
<P>The forms themselves are not hard to code. They follow the same constructs as
other HTML tags. What could be difficult is the program or script that takes the
information submitted in a form and processes it. Because of the need for
specialized scripts to handle the incoming form information, <A
href="/SDG/Software/Mosaic/Docs/fill-out-forms/overview.html">fill-out forms</A>
are not discussed in this primer. Check the <A href="#AR">Additional Online
Reference</A> section for more information.
<P>
<H2><A name=TR>Troubleshooting</A></H2>
<P>
<H4 align=left><A name=AO>Avoid Overlapping Tags</A></H4>
<P>
<P>Consider this example of HTML: <p> <B>This is an example of <I>overlapping</B> HTML tags.</I></p>
<P>The word <I>overlapping</I> is contained within both the <TT><B></TT>
and <TT><I></TT> tags. A browser might be confused by this coding and
might not display it the way you intend. The only way to know is to check each
popular browser (which is time-consuming and impractical).
<P>In general, avoid overlapping tags. Look at your tags and try pairing them
up. Tags (with the obvious exceptions of elements whose end tags may be omitted,
such as paragraphs) should be paired without an intervening tag in between. Look
again at the example above. You cannot pair the bold tags without another tag in
the middle (the first definition tag). Try matching your coding up like this to
see if you have any problem areas that should be fixed before you release your
files to a server.
<H4 align=left><A name=OE>Embed Only Anchors and Character Tags</A></H4>
<P>HTML protocol allows you to embed links within other HTML tags: <p> <H1><A HREF="Destination.html">My heading</A></H1></p>
<P><EM>Do not</EM> embed HTML tags within an anchor: <p> <A HREF="Destination.html"> <H1>My heading</H1> </A></p>
<P>Although most browsers currently handle this second example, the official
HTML specifications do not support this construct and your file will probably
not work with future browsers. Remember that browsers can be forgiving when
displaying improperly coded files. But that forgiveness may not last to the next
version of the software! When in doubt, code your files according to the HTML
specifications (see <A href="#FM">For More Information</A> below).
<P>Character tags modify the appearance of the text within other elements: <p> <UL> <LI><B>A bold list item</B> <LI><I>An italic list item</I> </UL></p>
<P>Avoid embedding other types of HTML element tags. For example, you might be
tempted to embed a heading within a list in order to make the font size larger: <p> <UL> <LI><H1>A large heading</H1> <LI><H2>Something slightly smaller</H2> </UL></p>
<P>Although some browsers handle this quite nicely, formatting of such coding is
unpredictable (because it is undefined). For compatibility with all browsers,
avoid these kinds of constructs. (The Netscape <FONT> tag, which lets you
specify how large individual characters will be displayed in your window, is not
currently part of the official HTML specifications.)
<P>What's the difference between embedding a <TT><B></TT> within a
<TT><LI></TT> tag as opposed to embedding a <TT><H1></TT> within a
<TT><LI></TT>? Within HTML the semantic meaning of <TT><H1></TT> is
that it's the main heading of a document and that it should be followed by the
content of the document. Therefore it doesn't make sense to find a
<TT><H1></TT> within a list.
<P>Character formatting tags also are generally not additive. For example, you
might expect that: <p> <B><I>some text</I></B></p>
<P>would produce bolditalic text. On some browsers it does; other browsers
interpret only the innermost tag.
<H4 align=left><A name=FS>Do the Final Steps </A></H4>
<P>
<H4 align=left>Validate Your Code</H4>
<P>When you put a document on a Web server, be sure to check the formatting and
each link (including named anchors). Ideally you will have someone else read
through and comment on your file(s) before you consider a document finished.
<P>You can run your coded files through one of several online <A
href="http://dir.yahoo.com/Computers_and_Internet/Information_and_Documentation/Data_Formats/HTML/Validation_and_Checkers/">HTML
validation service</A> that will tell you if your code conforms to accepted
HTML. If you are not sure your coding conforms to HTML specifications, this can
be a useful teaching tool. Fortunately the service lets you select the level of
conformance you want for your files (i.e., strict, level 2, level 3). If you
want to use some codes that are not officially part of the HTML specifications,
this latitude is helpful.
<H4 align=left>Dummy Images</H4>
<P>When an <TT><IMG SRC></TT> tag points to an image that does not exist,
a dummy image is substituted by your browser software. When this happens during
your final review of your files, make sure that the referenced image does in
fact exist, that the hyperlink has the correct information in the URL, and that
the file permission is set appropriately (world-readable). Then check online
again!
<P>
<H4 align=left>Update Your Files</H4>
<P>If the contents of a file are static (such as a biography of George
Washington), no updating is probably needed. But for documents that are time
sensitive or covering a field that changes frequently, <B>remember to update
your documents!</B>
<P>Updating is particularly important when the file contains information such as
a weekly schedule or a deadline for a program funding announcement. Remove
out-of-date files or note why something that appears dated is still on a server
(e.g., the program requirements will remain the same for the next cycle so the
file is still available as an interim reference).
<H4 align=left>Browsers Differ</H4>
<P>Web browsers display HTML elements differently. Remember that not all codes
used in HTML files are interpreted by all browsers. Any code a browser does not
understand is usually ignored though.
<P>You could spend a lot of time making your file "look perfect" using your
current browser. If you check that file using another browser, it will likely
display (a little or a lot) differently. Hence these words of advice: code your
files using correct HTML. Leave the interpreting to the browsers and hope for
the best.
<H4 align=left><A name=CO>Commenting Your Files</A></H4>
<P>You might want to include comments in your HTML files. Comments in HTML are
like comments in a computer program--the text you enter is not used by the
browser in any formatting and is not directly viewable by the reader just as
computer program comments are not used and are not viewable. The comments are
accessible if a reader views the source file, however.
<P>Comments such as the name of the person updating a file, the software and
version used in creating a file, or the date that a minor edit was made are the
norm.
<P>To include a comment, enter: <p> <!-- <I>your comments here</I> --></p>
<P>You must include the exclamation mark and the hyphens as shown.</P>](/img/Definition.jpg)
html codingHTML documents are plaintext (also known as ASCII) files that can be created using any text editor.
An element is a fundamental component of the structure of a text
document. Some examples of elements are heads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file for your browser. Elements can contain plain text, other elements, or both. To denote the various elements in an HTML document, you use tags. HTML tags consist of a left angle bracket (<), a tag name, and a right angle bracket (>). Tags are usually paired (e.g., <H1> and </H1>) to start and end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text within the brackets. HTML tags are listed below. Some elements may include an attribute, which is additional information that is included inside the start tag. For example, you can specify the alignment of images (top, middle, or bottom) by including the appropriate attribute with the image source HTML code. Tags that have optional attributes are noted below. NOTE: HTML is not case sensitive. <title> is
equivalent to <TITLE> or <TiTlE>. There are a few exceptions noted in Escape Sequences below.
Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it will simply ignore it. Any text placed between a pair of unknown tags will still be displayed, however.
Every HTML document should contain certain standard HTML tags. Each document consists of head and body text. The head contains the title, and the body contains the actual text that is made up of paragraphs, lists, and other elements. Browsers expect specific information because they are programmed according to HTML and SGML specifications.
Required elements are shown in this sample barebones document:
<html> <head> <TITLE>A Simple HTML Example</TITLE> </head> <body> <H1>HTML is Easy To Learn</H1> <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph!</P> <P>And this is the second paragraph.</P> </body> </html>
The required elements are the <html>, <head>,
<title>, and <body> tags (and their corresponding
end tags). Because you should include these tags in each file, you might want to
create a template file with them. (Some browsers will format your HTML file
correctly even if these tags are not included. But some browsers won't! So make
sure to include them.)
This element tells your browser that the file contains HTML-coded
information. The file extension .html also indicates this an HTML
document and must be used. (If you are restricted to 8.3 filenames (e.g.,
LeeHome.htm, use only .htm for your extension.)
The head element identifies the first part of your HTML-coded document that
contains the title. The title is shown as part of your browser's window (see
below).
The title element contains your document title and identifies its content in
a global context. The title is typically displayed in the title bar at the top
of the browser window, but not inside the window itself. The title is also what
is displayed on someone's hotlist or bookmark list, so choose something
descriptive, unique, and relatively short. A title is also used to identify your
page for search engines (such as HotBot or
Infoseek).
For example, you might include a shortened title of a book along with the
chapter contents: NCSA Mosaic Guide (Windows): Installation. This tells
the software name, the platform, and the chapter contents, which is more useful
than simply calling the document Installation. Generally you should keep
your titles to 64 characters or fewer.
The second--and largest--part of your HTML document is the body, which
contains the content of your document (displayed within the text area of your
browser window). The tags explained below are used within the body of your HTML
document.
HTML has six levels of headings, numbered 1 through 6, with 1 being the
largest. Headings are typically displayed in larger and/or bolder fonts than
normal body text. The first heading in each document should be tagged
<H1>.
The syntax of the heading element is:
<Hy>Text of heading
</Hy> where y is a number between 1 and 6
specifying the level of the heading.
Do not skip levels of headings in your document. For example, don't start
with a level-one heading (<H1>) and then next use a level-three
(<H3>) heading.
Unlike documents in most word processors, carriage returns in HTML files
aren't significant. In fact, any amount of whitespace -- including
spaces, linefeeds, and carriage returns -- are automatically compressed into a
single space when your HTML document is displayed in a browser. So you don't
have to worry about how long your lines of text are. Word wrapping can occur at
any point in your source file without affecting how the page will be displayed.
In the barebones example shown in the Minimal HTML Document section, the
first paragraph is coded as
<P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph!</P>
In the source file there is a line break between the sentences. A Web browser ignores this line break and starts a new paragraph only when it encounters another <P> tag.
Important: You must indicate paragraphs with <P>
elements. A browser ignores any indentations or blank lines in the source text.
Without <P> elements, the document becomes one large paragraph.
(One exception is text tagged as "preformatted," which is explained below.) For
example, the following would produce identical output as the first bare-bones
HTML example:
<H1>Levelone heading</H1> <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph! </P> <P>And this is the second paragraph.</P>
To preserve readability in HTML files, put headings on separate lines, use a
blank line or two where it helps identify the start of a new section, and
separate paragraphs with blank lines (in addition to the <P>
tags). These extra spaces will help you when you edit your files (but your
browser will ignore the extra spaces because it has its own set of rules on
spacing that do not depend on the spaces you put in your source file).
NOTE: The </P> closing tag may be omitted. This is
because browsers understand that when they encounter a <P> tag,
it means that the previous paragraph has ended. However, since HTML now allows
certain attributes to be assigned to the <P> tag, it's generally
a good idea to include it.
Using the <P> and </P> as a paragraph container
means that you can center a paragraph by including the
ALIGN=alignment attribute in your source file. <TT><P ALIGN=CENTER></TT> This is a centered paragraph. [See the formatted version below.] </P>
This is a centered paragraph.
It is also possible to align a paragraph to the right instead, by including
the ALIGN=RIGHT attribute. ALIGN=LEFT is the default
alignment; if no ALIGN attribute is included, the paragraph will be
leftaligned.
HTML supports unnumbered, numbered, and definition lists. You can nest lists
too, but use this feature sparingly because too many nested items can get
difficult to follow.
Unnumbered Lists
To make an unnumbered, bulleted list,
- start with an opening list <UL> (for unnumbered list) tag
- enter the <LI> (list item) tag followed by the individual
item; no closing </LI> tag is needed
- end the entire list with a closing list </UL> tag
Below is a sample threeitem list: <UL> <LI> apples <LI> bananas <LI> grapefruit </UL>
The output is:
- apples
- bananas
- grapefruit
The <LI> items can contain multiple paragraphs. Indicate the
paragraphs with the <P> paragraph tags.
Numbered Lists
A numbered list (also called an ordered list, from which the tag name
derives) is identical to an unnumbered list, except it uses <OL>
instead of <UL>. The items are tagged using the same
<LI> tag. The following HTML code: <OL> <LI> oranges <LI> peaches <LI> grapes </OL>
produces this formatted output:
- oranges
- peaches
- grapes
Definition Lists
A definition list (coded as <DL>) usually consists of
alternating a definition term (coded as <DT>) and a
definition definition (coded as <DD>). Web browsers generally
format the definition on a new line and indent it.
The following is an example of a definition list: <DL> <DT> NCSA <DD> NCSA, the National Center for Supercomputing Applications, is located on the campus of the University of Illinois at Urbana-Champaign. <DT> Cornell Theory Center <DD> CTC is located on the campus of Cornell University in Ithaca, New York. </DL>
The output looks like:
- NCSA
- NCSA, the National Center for Supercomputing Applications, is located on the
campus of the University of Illinois at Urbana-Champaign.
- Cornell Theory Center
- CTC is located on the campus of Cornell University in Ithaca, New York.
The <DT> and <DD> entries can contain multiple
paragraphs (indicated by <P> paragraph tags), lists, or other
definition information.
The COMPACT attribute can be used routinely in case your definition
terms are very short. If, for example, you are showing some computer options,
the options may fit on the same line as the start of the definition. <DL COMPACT><DT> -i<DD>invokes NCSA Mosaic for Microsoft Windows using the initialization file defined in the path<DT> -k<DD>invokes NCSA Mosaic for Microsoft Windows in kiosk mode</DL>
The output looks like:
- -i
- invokes NCSA Mosaic for Microsoft Windows using the initialization file
defined in the path.
- -k
- invokes NCSA Mosaic for Microsoft Windows in kiosk mode.
Nested Lists
Lists can be nested. You can also have a number of paragraphs, each
containing a nested list, in a single list item.
Here is a sample nested list: <UL> <LI> A few New England states: <UL> <LI> Vermont <LI> New Hampshire <LI> Maine </UL> <LI> Two Midwestern states: <UL> <LI> Michigan <LI> Indiana </UL> </UL>
The nested list is displayed as
- A few New England states:
- Vermont
- New Hampshire
- Maine
- Two Midwestern states:
Use the<PRE> tag (which stands for "preformatted") to generate
text in a fixedwidth font. This tag also makes spaces, new lines, and tabs
significant -- multiple spaces are displayed as multiple spaces, and lines break
in the same locations as in the source HTML file. This is useful for program
listings, among other things. For example, the following lines: <PRE> #!/bin/csh cd $SCR cfs get mysrc.f:mycfsdir/mysrc.f cfs get myinfile:mycfsdir/myinfile fc -02 -o mya.out mysrc.f mya.out cfs save myoutfile:mycfsdir/myoutfile rm * </PRE>
display as: #!/bin/csh cd $SCR cfs get mysrc.f:mycfsdir/mysrc.f cfs get myinfile:mycfsdir/myinfile fc -02 -o mya.out mysrc.f mya.out cfs save myoutfile:mycfsdir/myoutfile rm *
The <PRE> tag can be used with an optional WIDTH
attribute that specifies the maximum number of characters for a line.
WIDTH also signals your browser to choose an appropriate font and
indentation for the text.
Hyperlinks can be used within <PRE> sections. You should avoid
using other HTML tags within <PRE> sections, however.
Note that because <, >, and & have special meanings in HTML, you
must use their escape sequences (<, >, and
&, respectively) to enter these characters. See the section Escape Sequences for more information.
Use the <BLOCKQUOTE> tag to include lengthy quotations in a
separate block on the screen. Most browsers generally change the margins for the
quotation to separate it from surrounding text.
In the example: <P>Omit needless words.</P> <BLOCKQUOTE> <P>Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. </P> <P>--William Strunk, Jr., 1918 </P> </BLOCKQUOTE>
the result is:
Omit needless words.
Vigorous writing is concise. A sentence should contain no unnecessary words,
a paragraph no unnecessary sentences, for the same reason that a drawing should
have no unnecessary lines and a machine no unnecessary parts.
--William Strunk, Jr., 1918
The <BR> tag forces a line break with no extra (white) space
between lines. Using <P> elements for short lines of text such as
postal addresses results in unwanted additional white space. For example, with
: National Center for Supercomputing Applications<BR> 605 East Springfield Avenue<BR> Champaign, Illinois 61820-5518<BR>
The output is:
National Center for Supercomputing Applications 605 East Springfield
Avenue Champaign, Illinois 61820-5518
The <HR> tag produces a horizontal line the width of the
browser window. A horizontal rule is useful to separate major sections of your
document.
You can vary a rule's size (thickness) and width (the percentage of the
window covered by the rule). Experiment with the settings until you are
satisfied with the presentation. For example: <HR SIZE=4 WIDTH="50%">
displays as:
HTML has two types of styles for individual words or sentences: logical and
physical. Logical styles tag text according to its meaning, while
physical styles indicate the specific appearance of a section. For
example, in the preceding sentence, the words "logical styles" was tagged as
"emphasis." The same effect (formatting those words in italics) could have been
achieved via a different tag that tells your browser to "put these words in
italics."
If physical and logical styles produce the same result on the screen, why are
there both?
In the ideal SGML universe, content is divorced from presentation. Thus SGML
tags a level-one heading as a level-one heading, but does not specify that the
level-one heading should be, for instance, 24-point bold Times centered. The
advantage of this approach (it's similar in concept to style sheets in many word
processors) is that if you decide to change level-one headings to be 20-point
left-justified Helvetica, all you have to do is change the definition of the
level-one heading in your Web browser. Indeed, many browsers today let you
define how you want the various HTML tags rendered on-screen using what are
called cascading style sheets, or CSS. CSS is more advanced than HTML,
though, and will not be covered in this Primer. (You can learn more about CSS at
the World Wide Web Consortium CSS site.)
Another advantage of logical tags is that they help enforce consistency in
your documents. It's easier to tag something as <H1> than to
remember that levelone headings are 24-point bold Times centered or whatever.
For example, consider the <STRONG> tag. Most browsers render it
in bold text. However, it is possible that a reader would prefer that these
sections be displayed in red instead. (This is possible using a local cascading
style sheet on the reader's own computer.) Logical styles offer this
flexibility.
Of course, if you want something to be displayed in italics (for example) and
do not want a browser's setting to display it differently, you should use
physical styles. Physical styles, therefore, offer consistency in that something
you tag a certain way will always be displayed that way for readers of your
document.
Try to be consistent about which type of style you use. If you tag with
physical styles, do so throughout a document. If you use logical styles, stick
with them within a document. Keep in mind that future releases of HTML might not
support certain logical styles, which could mean that browsers will not display
your logical-style coding. (For example, the <DFN> tag -- short
for "definition", and typically displayed in italics -- is not widely supported
and will be ignored if the reader's browser does not understand it.)
Logical Styles
- <DFN>
- for a word being defined. Typically displayed in italics. (NCSA
Mosaic is a World Wide Web browser.)
- <EM>
- for emphasis. Typically displayed in italics. (Consultants cannot reset
your password unless you call the help line.)
- <CITE>
- for titles of books, films, etc. Typically displayed in italics. (A
Beginner's Guide to HTML)
- <CODE>
- for computer code. Displayed in a fixed-width font. (The
<stdio.h> header file)
- <KBD>
- for user keyboard entry. Typically displayed in plain fixed-width font.
(Enter passwd to change your password.)
- <SAMP>
- for a sequence of literal characters. Displayed in a fixed-width font.
(Segmentation fault: Core dumped.)
- <STRONG>
- for strong emphasis. Typically displayed in bold. (NOTE:
Always check your links.)
- <VAR>
- for a variable, where you will replace the variable with specific
information. Typically displayed in italics. (rm filename
deletes the file.)
Physical Styles
- <B>
- bold text
- <I>
- italic text
- <TT>
- typewriter text, e.g. fixed-width font.
Character entities have two functions:
- escaping special characters
- displaying other characters not available in the plain ASCII character set
(primarily characters with diacritical marks)
Three ASCII characters--the left angle bracket (<), the right angle
bracket (>), and the ampersand (&)--have special meanings in HTML and
therefore cannot be used "as is" in text. (The angle brackets are used to
indicate the beginning and end of HTML tags, and the ampersand is used to
indicate the beginning of an escape sequence.) Double quote marks may be used
as-is but a character entity may also be used (").
To use one of the three characters in an HTML document, you must enter its
escape sequence instead:
- <
- the escape sequence for <
- >
- the escape sequence for >
- &
- the escape sequence for &
Additional escape sequences support accented characters, such as:
- ö
- a lowercase o with an umlaut: ö
- ñ
- a lowercase n with a tilde: ñ
- È
- an uppercase E with a grave accent: È
You can substitute other letters for the o, n, and E
shown above. Visit the World Wide Web Consortium for a complete list of special
characters.
NOTE: Unlike the rest of HTML, the escape sequences are case
sensitive. You cannot, for instance, use < instead of
<.
The chief power of HTML comes from its ability to link text and/or an image
to another document or section of a document. A browser highlights the
identified text or image with color and/or underlines to indicate that it is a
hypertext link (often shortened to hyperlink or just link).
HTML's single hypertextrelated tag is <A>, which stands for
anchor. To include an anchor in your document:
- start the anchor with <A (include a space after the A)
- specify the document you're linking to by entering the parameter
HREF="filename" followed by a closing right angle
bracket (>)
- enter the text that will serve as the hypertext link in the current document
- enter the ending anchor tag: </A> (no space is needed before
the end anchor tag)
Here is a sample hypertext reference in a file called US.html: <A HREF="MaineStats.html">Maine</A>
This entry makes the word Maine the hyperlink to the document
MaineStats.html, which is in the same directory as the first document.
You can link to documents in other directories by specifying the relative
path from the current document to the linked document. For example, a link
to a file NYStats.html located in the subdirectory
AtlanticStates would be: <A HREF="AtlanticStates/NYStats.html">New York</A>
These are called relative links because you are specifying the path to
the linked file relative to the location of the current file. You can also use
the absolute pathname (the complete URL) of the file, but relative links are
more efficient in accessing a server. They also have the advantage of making
your documents more "portable" -- for instance, you can create several web pages
in a single folder on your local computer, using relative links to hyperlink one
page to another, and then upload the entire folder of web pages to your web
server. The pages on the server will then link to other pages on the server, and
the copies on your hard drive will still point to the other pages stored there.
It is important to point out that UNIX is a casesensitive operating system
where filenames are concerned, while DOS and the MacOS are not. For instance, on
a Macintosh, "DOCUMENT.HTML", "Document.HTML", and "document.html" are all the
same name. If you make a relative hyperlink to "DOCUMENT.HTML", and the file is
actually named "document.html", the link will still be valid. But if you upload
all your pages to a UNIX web server, the link will no longer work. Be sure to
check your filenames before uploading.
Pathnames use the standard UNIX syntax. The UNIX syntax for the parent
directory (the directory that contains the current directory) is "..". (For more
information consult a beginning UNIX reference text such as Learning the UNIX
Operating System from O'Reilly and Associates, Inc.)
If you were in the NYStats.html file and were referring to the
original document US.html, your link would look like this: <A HREF="../US.html">United States</A>
In general, you should use relative links whenever possible because:
- it's easier to move a group of documents to another location (because the
relative path names will still be valid)
- it's more efficient connecting to the server
- there is less to type
However, use absolute pathnames when linking to documents that are not
directly related. For example, consider a group of documents that comprise a
user manual. Links within this group should be relative links. Links to other
documents (perhaps a reference to related software) should use absolute
pathnames instead. This way if you move the user manual to a different
directory, none of the links would have to be updated.
The World Wide Web uses Uniform Resource Locators (URLs) to specify the
location of files on other servers. A URL includes the type of resource being
accessed (e.g., Web, gopher, FTP), the address of the server, and the location
of the file. The syntax is:
scheme://host.domain
[:port]/path/ filename
where scheme is one of
- file
- a file on your local system
- ftp
- a file on an anonymous FTP server
- http
- a file on a World Wide Web server
- gopher
- a file on a Gopher server
- WAIS
- a file on a WAIS server
- news
- a Usenet newsgroup
- telnet
- a connection to a Telnetbased service
The port number can generally be omitted. (That means unless someone
tells you otherwise, leave it out.)
For example, to include a link to this primer in your document, enter: <A HREF="http://www.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimer.html">NCSA's Beginner's Guide to HTML</A>
This entry makes the text NCSA's Beginner's Guide to HTML a hyperlink
to this document.
There is also a mailto scheme, used to hyperlink email addresses,
but this scheme is unique in that it uses only a colon (:) instead of
:// between the scheme and the address. You can read more about
mailto below.
For more information on URLs, refer to:
Anchors can also be used to move a reader to a particular section in a
document (either the same or a different document) rather than to the top, which
is the default. This type of an anchor is commonly called a named anchor
because to create the links, you insert HTML names within the document.
This guide is a good example of using named anchors in one document. The
guide is constructed as one document to make printing easier. But as one (long)
document, it can be time-consuming to move through when all you really want to
know about is one bit of information about HTML. Internal hyperlinks are used to
create a "table of contents" at the top of this document. These hyperlinks move
you from one location in the document to another location in the same document.
(Go to the top of this document and then click on the
Links to Specific Sections hyperlink in the table of contents. You will
wind up back here.)
You can also link to a specific section in another document. That information
is presented first because understanding that helps you understand linking
within one document.
Links Between Sections of Different Documents
Suppose you want to set a link from document A (documentA.html) to a
specific section in another document (MaineStats.html).
Enter the HTML coding for a link to a named anchor: documentA.html: In addition to the many state parks, Maine is also home to <a href="MaineStats.html#ANP">Acadia National Park</a>.
Think of the characters after the hash (#) mark as a tab within the
MaineStats.html file. This tab tells your browser what should be
displayed at the top of the window when the link is activated. In other words,
the first line in your browser window should be the Acadia National Park
heading.
Next, create the named anchor (in this example "ANP") in
MaineStats.html: <H2><A NAME="ANP">Acadia National Park</a></H2>
With both of these elements in place, you can bring a reader directly to the
Acadia reference in MaineStats.html.
NOTE: You cannot make links to specific sections within a different
document unless either you have write permission to the coded source of that
document or that document already contains indocument named anchors. For
example, you could include named anchors to this primer in a document you are
writing because there are named anchors in this guide (use View Source in your
browser to see the coding). But if this document did not have named
anchors, you could not make a link to a specific section because you cannot edit
the original file on NCSA's server.
Links to Specific Sections within the Current Document
The technique is the same except the filename is omitted.
For example, to link to the ANP anchor from within
MaineStats, enter: ...More information about <A HREF="#ANP">Acadia National Park</a> is available elsewhere in this document.
Be sure to include the <A NAME=> tag at the place in your
document where you want the link to jump to (<A NAME="ANP">Acadia
National Park</a>).
Named anchors are particularly useful when you think readers will print a
document in its entirety or when you have a lot of short information you want to
place online in one file.
You can make it easy for a reader to send electronic mail to a specific
person or mail alias by including the mailto attribute in a hyperlink.
The format is: <A HREF="mailto:emailinfo@host">Name</a>
For example, enter: <A HREF="mailto:pubs@ncsa.uiuc.edu"> NCSA Publications Group</a>
to create a mail window that is already configured to open a mail window for
the NCSA Publications Group alias. (You,
of course, will enter another mail address!)
Most Web browsers can display inline images (that is, images next to text)
that are in X Bitmap (XBM), GIF, or JPEG format. Other image formats are also
being incorporated into Web browsers [e.g., the Portable Network Graphic (PNG)
format]. Each image takes additional time to download and slows down the initial
display of a document. Carefully select your images and the number of images in
a document.
To include an inline image, enter: <IMG SRC=ImageName>
where ImageName is the URL of the image file.
The syntax for <IMG SRC> URLs is identical to that used in an
anchor HREF. If the image file is a GIF file, then the filename part of
ImageName must end with .gif. Filenames of X Bitmap images must
end with .xbm; JPEG image files must end with .jpg or
.jpeg; and Portable Network Graphic files must end with .png.
You should include two other attributes on <IMG> tags to tell
your browser the size of the images it is downloading with the text. The
HEIGHT and WIDTH attributes let your browser set aside the
appropriate space (in pixels) for the images as it downloads the rest of the
file. (You can get the pixel size from your image-processing software, such as
Adobe Photoshop. Some browsers will also display the dimensions of an image file
in the title bar if the image is viewed by itself without an enclosing HTML
document.)
For example, to include a self portrait image in a file along with the
portrait's dimensions, enter: <IMG SRC=SelfPortrait.gif HEIGHT=100 WIDTH=65>
NOTE: Some browsers use the HEIGHT and WIDTH
attributes to stretch or shrink an image to fit into the allotted space when the
image does not exactly match the attribute numbers. Not all browser developers
think stretching/shrinking is a good idea, so don't plan on your readers having
access to this feature. Check your dimensions and use the correct ones.
You have some flexibility when displaying images. You can have images
separated from text and aligned to the left or right or centered. Or you can
have an image aligned with text. Try several possibilities to see how your
information looks best.
Aligning Text with an Image By default the bottom of an image is
aligned with the following text, as shown in this paragraph. You can align
images to the top or center of a paragraph using the ALIGN= attributes
TOP and CENTER.
This text is aligned with the top of the image (<IMG SRC =
"BarHotlist.gif" ALT="[HOTLIST]" ALIGN=TOP>). Notice how the browser
aligns only one line and then jumps to the bottom of the image for the rest of
the text.
And this text is centered on the image (<IMG SRC = "BarHotlist.gif"
ALT="[HOTLIST]" ALIGN=CENTER>). Again, only one line of text is
centered; the rest is below the image.
Images without Text To display an image without any associated
text (e.g., your organization's logo), make it a separate paragraph. Use the
paragraph ALIGN= attribute to center the image or adjust it to the
right side of the window as shown below: <p ALIGN=CENTER><IMG SRC = "BarHotlist.gif" ALT="[HOTLIST]"></p>
which results in:
The image is centered; this paragraph starts below it and left justified.
Some World Wide Web browsers -- primarily the textonly browsers such as Lynx -- cannot display images. Some users
turn off image loading even if their software can display images (especially if
they are using a modem or have a slow connection). HTML provides a mechanism to
tell readers what they are missing on your pages if they can't load images.
The ALT attribute lets you specify text to be displayed instead of
an image. For example: <IMG SRC="UpArrow.gif" ALT="Up">
where UpArrow.gif is the picture of an upward pointing arrow. With
graphics-capable viewers that have image-loading turned on, you see the up arrow
graphic. With a text-only browser or if image-loading is turned off, the word
Up is shown in your window in place of the image.
You should try to include alternate text for each image you use in your
document, which is a courtesy for your readers -- or, for users who might be
visually impaired, a necessity.
Inline images can be used as hyperlinks just like plain text. The following
HTML code: <A HREF="hotlist.html"><IMG SRC="BarHotlist.gif" ALT="[HOTLIST]"></A>
Produces the following result:
(Note that this link doesn't actually go anywhere.) The blue border that
surrounds the image indicates that it's a clickable hyperlink. You may not
always want this border to be displayed, though. In this case you can use the
BORDER attribute of the IMG tag to make the image appear as normal. Adding the
BORDER attribute and setting it to zero: <A HREF="hotlist.html"><IMG SRC="BarHotlist.gif" BORDER=0 ALT="[HOTLIST]"></A>
Produces the following result:
The BORDER attribute can also be set to nonzero values, whether or not the
image is used as a hyperlink. In this case, the border will appear using the
default text color for the web page. For instance, if you wanted to give your
image a plain black border to help it stand out on the page, you might try this:
<IMG SRC="BarHotlist.gif" BORDER=6 ALT="[HOTLIST]">
And get the following result:
Newer versions of Web browsers can load an image and use it as a background
when displaying a page. Some people like background images and some don't. In
general, if you want to include a background, make sure your text can be read
easily when displayed on top of the image.
Background images can be a texture (linen finished paper, for example) or an
image of an object (a logo possibly). You create the background image as you do
any image.
However you only have to create a small piece of the image. Using a feature
called tiling, a browser takes the image and repeats it across and down to fill
your browser window. In sum you generate one image, and the browser replicates
it enough times to fill your window. This action is automatic when you use the
background tag shown below.
The tag to include a background image is included in the
<BODY> statement as an attribute: <BODY BACKGROUND="filename.gif">
By default browsers display text in black on a gray background. However, you
can change both elements if you want. Some HTML authors select a background
color and coordinate it with a change in the color of the text.
Always preview changes like this to make sure your pages are readable. (For
example, many people find red text on a black background difficult to read!) In
general, try to avoid using high-contrast images or images that use the color of
your text anywhere within the graphic.
You change the color of text, links, visited links, and active links (links
that are currently being clicked on) using further attributes of the
<BODY> tag. For example: <BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#9690CC">
This creates a window with a black background (BGCOLOR), white text
(TEXT), and silvery hyperlinks (LINK).
The sixdigit number and letter combinations represent colors by giving their
RGB (red, green, blue) value. The six digits are actually three two-digit
numbers in sequence, representing the amount of red, green, or blue as a
hexadecimal value in the range 00-FF. For example, 000000 is black (no color at
all), FF0000 is bright red, 0000FF is bright blue, and FFFFFF is white (fully
saturated with all three colors).
These number and letter combinations are generally rather cryptic.
Fortunately an online resource is available to help you track down the
combinations that map to specific colors and there is software available for you
to do this on your workstation:
For some basic colors -- typically those in the standard sixteencolor Windows
3.1 palette -- you can also use the name of the color instead of the
corresponding RGB value. For example, "black", "red", "blue", and "cyan" are all
valid for use in place of RGB values. However, while not all browsers will
understand all color names, any browser that can display colors will understand
RGB values, so use them whenever possible.
You may want to have an image open as a separate document when a user
activates a link on either a word or a smaller, inline version of the image
included in your document. This is called an external image, and it is useful if
you do not wish to slow down the loading of the main document with large inline
images.
To include a reference to an external image, enter: <A HREF="MyImage.gif">link anchor</A>
You can also use a smaller image as a link to a larger image. Enter: <A HREF="LargerImage.gif"><IMG SRC="SmallImage.gif"></A>
The reader sees the SmallImage.gif image and clicks on it to open
the LargerImage.gif file.
Use the same syntax for links to external animations and sounds. The only
difference is the file extension of the linked file. For example,
<A HREF="AdamsRib.mov">link anchor</A>
specifies a link to a QuickTime movie. Some common file types and their
extensions are:
- plain text
- .txt
- HTML document
- .html
- GIF image
- .gif
- TIFF image
- .tiff
- X Bitmap image
- .xbm
- JPEG image
- .jpg or .jpeg
- PostScript file
- .ps
- AIFF sound file
- .aiff
- AU sound file
- .au
- WAV sound file
- .wav
- QuickTime movie
- .mov
- MPEG movie
- .mpeg or .mpg
Keep in mind your intended audience and their access to software. Most UNIX
workstations, for instance, cannot view QuickTime movies.
Before HTML tags for tables were finalized, authors had to carefully format
their tabular information within <PRE> tags, counting spaces and
previewing their output. Tables are very useful for presentation of tabular
information as well as a boon to creative HTML authors who use the table tags to
present their regular Web pages. (Check out the NCSA home page for an excellent example of
using tables to control page layout.)
Think of your tabular information in light of the coding explained below. A
table has heads where you explain what the columns/rows include, rows for
information, cells for each item. In the following table, the first column
contains the header information, each row explains an HTML table tag, and each
cell contains a paired tag or an explanation of the tag's function.
|
| Element |
Description |
| <TABLE> ... </TABLE> |
defines a table in HTML. If the BORDER attribute is present, your
browser displays the table with a border. |
| <CAPTION> ... </CAPTION> |
defines the caption for the title of the table. The default position of the
title is centered at the top of the table. The attribute ALIGN=BOTTOM
can be used to position the caption below the table. NOTE: Any kind
of markup tag can be used in the caption. |
| <TR> ... </TR> |
specifies a table row within a table. You may define default attributes for
the entire row: ALIGN (LEFT, CENTER, RIGHT)
and/or VALIGN (TOP, MIDDLE, BOTTOM). See
Table Attributes at the end of this table for more information. |
| <TH> ... </TH> |
defines a table header cell. By default the text in this cell is bold and
centered. Table header cells may contain other attributes to determine the
characteristics of the cell and/or its contents. See Table Attributes at the end
of this table for more information. |
| <TD> ... </TD> |
defines a table data cell. By default the text in this cell is aligned left
and centered vertically. Table data cells may contain other attributes to
determine the characteristics of the cell and/or its contents. See Table
Attributes at the end of this table for more information.
|
|
|
| NOTE: Attributes defined within
<TH> ... </TH> or <TD> ...
</TD> cells override the default alignment set in a
<TR> ... </TR>. |
| Attribute |
Description |
| ALIGN (LEFT, CENTER, RIGHT) |
Horizontal alignment of a cell. |
| VALIGN (TOP, MIDDLE, BOTTOM) |
Vertical alignment of a cell. |
| COLSPAN=n |
The number (n) of columns a cell spans. |
| ROWSPAN=n |
The number (n) of rows a cell | |