Basics of HTML Hypertext Markup Language

part 1 | part 2 | link to html resources

  • Format text, graphics, sound, and video so other computers can read or see your data.
  • Permits links between documents.
  • Allows browsers to interpret the information on the screen.

Part 2-Table of Contents


Lists 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. Return to Table of Contents
Unnumbered Lists )or unordered lists)Return to Table of Contents To make an unnumbered, bulleted list,

  1. start with an opening list <ul> (for unnumbered list) tag,
  2. enter the <li> (list item) tag followed by the individual item; no closing </li> tag is needed,
  3. end the entire list with a closing list </ul> tag.

Below is a sample three-item list:

<ul>

<li> apples</li>

<li> bananas</li>

<li> grapefruit</li>

</ul>

The output is:

  • apples
  • bananas
  • grapefruit

The <li> items can contain multiple paragraphs. Indicate the paragraphs with the <p> paragraph tag or the <br> break tag.
Numbered Lists )or Ordered Lists)Return to Table of Contents 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>

<li> peaches</li>

<li> grapes</li>

</ol>

produces this formatted output:

  1. oranges
  2. peaches
  3. grapes


List AttributesYou can use letters or different numbers or symbols if you set attributes for the lists. HTML code:

<ol type="A" start="1">

<li> oranges</li>

<li> peaches</li>

<li> grapes</li>

</ol>

produces this formatted output:

  1. oranges
  2. peaches
  3. grapes

For the Symbols in a ul list, this is the coding:

<ul type=square>

<li> apples</li>

<li> bananas</li>

<li> grapefruit</li>

</ul>

The output is for square is:

  • apples
  • bananas
  • grapefruit

The output is for circle is:

  • apples
  • bananas
  • grapefruit

Symbols available are: disc, square, circle, or none. None can also be achieve by leaving off the <li>. Nested lists produce different symbols.

Definition Lists Return to Table of Contents 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. The following is an example of a definition list:

<dl>

<dt> NCSA</dt>

<dd> NCSA, the National Center for Supercomputing Applications, is located on the campus of the University of Illinois at Urbana-Champaign.</dd>

<dt> Cornell Theory Center</dt>

<dd> CTC is located on the campus of Cornell University in Ithaca, New York.</dd>

</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.

Nested Lists Return to Table of Contents 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:</li>

<ul>

<li> Vermont</li>

<li> New Hampshire</li>

<li> Maine</li>

</ul>

<li> Two Midwestern states:</li>

<ul>

<li> Michigan</li>

<li> Indiana</li>

</ul>

</ul>

The nested list is displayed as:

  • A few New England states and their capitols:
    • Vermont
      • Burlington
    • New Hampshire
      • Concord
    • Connecticut
      • Hartford
  • Two Midwestern states and their capitols:
    • Illinois
      • Springfield
    • Indiana
      • Indianapolis


Inline Images Return to Table of Contents Most Web browsers can display inline images (that is, images next to text) that are in X Bitmap (XBM), GIF, or JPEG format. Each image takes time to process 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. IMG SRC means Image Source, i.e. the name and place where the image file resides. 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. JPEG image files must end with.jpg or.jpeg.
Image Size Attributes Return to Table of Contents 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. (Get the pixel size from your image-processing software, such as Adobe Photoshop.) 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> Regular size: -- -- Scaled: HEIGHT=25 WIDTH=25 -- -- 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.

Aligning Images Return to Table of Contents 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. The artist's palette is align=left and the corvette is align=right.

Aligning Text with an Image Return to Table of Contents By default the bottom of an image is aligned with the following text. You can align images to the top or center of a paragraph using the AliGN= attributes TOP and CENTER. Example: <IMG src="coloflag.GIF" AliGN= TOP>. Notice 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 = "coloflag.GIF AliGN= CENTER>). Again, only one line of text is centered; the rest is below the image. Other Alignments include: <IMG src="coloflag.GIF" AliGN= BASEliNE> - where the paragraph extends below the image. <IMG src="coloflag.GIF" AliGN= TEXTTOP> - where the paragraph extends below the image. <IMG src="coloflag.GIF" AliGN= ABSMIDDLE> - where the line of textstarts from the absolute middle of the image, versus the center. <IMG src="coloflag.GIF" AliGN=ABSBOTTOM> - where the paragraph extends below the image.
Images without Text Return to Table of Contents 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 = "njclogo_plain.gif border="3""> </p> Note the additional attribute: BORDER="3" --- 3 being the size of the black border.< BR>
Alternate Text for Images )Return to Table of Contents)
Some old World Wide Web browsers 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). Some users who are visually disabled have the browser read to them by special software. HTML provides a mechanism to tell readers what they are missing on your pages. The ALT attribute lets you specify text to be displayed instead of an image. It is proper HTML to always use an "ALT=" attribute. For example: <IMG src="arrow-u.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 VT100 browser or if image-loading is turned off, the word Up is shown in your window. You should try to include alternate text for each image you use in your document, which is a courtesy for your readers. For images with no meaning use quotes with nothing between them. <IMG src="anything.gif" ALT=""> Besides courtesy, why bother with the "ALT=" attribute? If you make your image a link with an A href=, in the non-graphical browser, the ALT= word becomes the link. HTML Code:

<A href="#TopToC"><IMG src="arrow-u.gif" ALT="UP"</A> Return to Table of Contents

Produces this in a graphical browser:

UP Return to Table of Contents


Linking (Return to Table of Contents)
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 link). HTML's single hypertext-related tag is <A>, which stands for anchor. To include an anchor in your document:

  1. start the anchor with <A (include a space after the A)
  2. specify the document you're linking to by entering the parameter href="filename" followed by a closing right angle bracket (>)
  3. enter the text that will serve as the hypertext link in the current document
  4. 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.< BR>
Relative Pathnames Versus Absolute Pathnames )Return to Table of Contents)
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. Pathnames use the standard UNIX syntax. The UNIX syntax for the parent directory (the directory that contains the current directory) is "..". 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 because:

  1. it's easier to move a group of documents to another location (because the relative path names will still be valid)
  2. it's more efficient connecting to the server
  3. 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 full path names. This way if you move the user manual to a different directory, none of the links would have to be updated.

URLs )Return to Table of Contents)
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, WAIS), 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 Telnet-based service

The port number can generally be omitted. (That means unless someone tells you otherwise, leave it out.) or example, to include a link to this primer in your document, enter: <A href="http://archive.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimerAll.html"> NCSA's Beginner's Guide to HTML</A> This entry makes the text -- NCSA's Beginner's Guide to HTML -- a hyperlink to that document.

Links to Specific Sections )Return to Table of Contents)
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. (Return to Table of Contents 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 )Return to Table of Contents)
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 in 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.
Links to Specific Sections within the Current Document )Return to Table of Contents)
The technique is the same except the filename is omitted. For example, to link to the ANP anchor from within MaineStats.html, 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 (<H2><A NAME="ANP">Acadia National Park</a></H2>). 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.
MailtoReturn to Table of Contents 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!)

Link to Part 1| Link to HTML Resources


Adapted from the simplified revision of the HTML Primer by NCSA found at this address:
/  for the organization of this demonstration of tags goes to Paul S. Hoffman and Molly Youngkin of the , Omaha, Nebraska.Page researched and written by Rosalind F. Dudden, Health Sciences Librarian,
Gerald Tucker Memorial Medical Library, National Jewish Health.
Developed for the course, website Planning and Basic HTML, for the Central Colorado Library System in 1996; Revised 1997; Revised 2003.