Lab 5

Basic HTML

 

 

[Turnin: A working web page]

Objectives

  1. Learn what HTML is, and how it works.
  2. Learn what a tag is.
  3. Learn what a link is.
  4. Learn where to create HTML files.
  5. Create your own web page.



What is HTML

Hypertext Markup Language (HTML) is a scripting language used to create web pages. Browsers such as Netscape and Internet Explorer then parse the HTML and generate web pages readable by us. One of the best ways to learn how HTML works is to look at existing code. To view the HTML code for an existing web page, do the following:

  1. Start Netscape.
  2. Select the "View" menu option.
  3. Select "Page Source".

You are now looking at the HTML code for the web page that is currently displayed in your browser.

When looking at HTML, you will notice that much of it looks like English text. The small portion of words enclosed in greater and less than signs "<" and ">" are the actual HTML instructions. These instructions, called tags, tell the web browser how to format the text and images you want to display.

 

Basic Parts of an HTML Document

Tags and content are the two basic parts that make up an HTML document. Tags are the instructions that tell the browser how to format the contents you want to display. Content is usually text and images, although there are special cases, such as PERL and Java scripts, which are not displayed.

 

 

Tag

Tag Name

Optional Parameters

Purpose/Usage

<HTML>

</HTML>

Html

None

Used to denote the start of HTML code.

<HEAD>

</HEAD>

Head

None

Sets general properties of the web page. Usually just contains the <TITLE> tag.

<TITLE>

</TITLE>

Title

None

Sets the title of the web page.

<BODY>

</BODY>

Body

background="image.jpg"

bgcolor="#RRGGBB"

link="#RRGGBB"

vlink="#RRGGBB"

alink="#RRGGBB"

text="#RRGGBB"

Contains the majority of the HTML code. Is also used to set general properties for text, links, and background.

Background is used to set the background of your web page to a specific image. This is accomplished by setting "image.jpg" to the name of your image.

Bgcolor is used to set the entire background to one of 16 million colors. To understand how to set background and other colors, see the section SETTING COLORS below.

Link is used to set the color of all links.

Vlink is used to set the color of visited links.

Alink is used to set the color of active links.

Text is used to set the color of all text.

 

 

Tag

Tag Name

Optional Parameters

Purpose/Usage

<Hx>

</Hx>

Heading

None

Sets the size of the text that is in between the opening and closing tags. The size is set by replacing the "x" in <Hx> or </Hx> with a number from 1 (very large) to 6 (very small).

<B>

</B>

Bold

None

Bolds the text between the opening and closing tags.

<I>

</I>

Italics

None

Italicizes the text between the opening and closing tags.

<U>

</U>

Underline

None

Underlines the text between the opening and closing tags.

<CENTER>

</CENTER>

Center

None

Centers the text between the opening and closing tags.

<FONT>

</FONT>

Font

size=x

color="#RRGGBB"

Sets the font color and font size of text that is between the opening and closing tags.

Set size by replacing "x" in "size=x" with some integer value.

To understand how color works, see the section SETTING COLORS below.

<PRE>

</PRE>

Preformatted

None

Tells your web browser that everything in between the opening and closing tags is already formatted. This will display the text "as is".

<P>

</P>

Paragraph

align="x"

Tells your web browser that everything in between the opening and closing tags should be formatted like a paragraph. This is also used to set the alignment of the paragraph. Replace "x" with either LEFT, CENTER, or RIGHT.

 

Tag

Tag Name

Optional Parameters

Purpose/Usage

<IMG>

Image

src="source.jpg"

height=x

width=x

border=x

alt="some text"

align="x"

usemap="#mapname"

Tells the web browser that you want to display this image in your HTML document. Replace "source.jpg" with the name of your image file.

Replacing the "x" in width or height with a numeric value will set image width and height, respectively.

Set a border around your image by setting the "x" in "border=x" to some numeric value.

Alt is used to specify what text you want to display instead of the image if the image cannot be displayed.

Align is used to align the text in the alt field.

Usemap is used to create an image map. This will be discussed in the second HTML lab.

 

Tag

Tag Name

Optional Parameters

Purpose/Usage

<A>

Anchor

HREF="www.somepage.org"

HREF="mailto:email@domain"

NAME="top"

Binds text or an image to the action specified by an optional parameter.

The HREF parameter either contains a web address to jump to or a special tag command such as mailto.

The NAME parameter is used to give this location a name. That way you can jump to this specific location. Reference this location with #AnchorName.

 

Tag

Tag Name

Optional Parameters

Purpose/Usage

<!-- -->

Comment Delimiter

None

Anything in between the greater than and less than signs is ignored by your web browser. This makes it particularly useful for writing comments.

<BR>

Break

None

Break behaves like a carriage return. <BR> shoves the rest of the HTML content to the next line, all the way at the left hand side of the screen.

<HR>

Horizontal Rule

size=x

width=x

The horizontal rule is a horizontal line that goes across your web page.

Size specifies the thickness of the horizontal rule, where "x" is some numeric value.

Width specifies how far across the web page the line should go. This length can either be a percentage of your web page, such as 80%, or an absolute number of pixels, such as 400.

 

 

Setting Colors

There are more than 16 million possible colors that can be used for setting things such as background, text, and link colors. These colors are set as optional parameters for a given HTML tag. Take, for example, <BODY bgcolor="#0000FF">. The optional parameter is bgcolor, which is part of the BODY tag. The actual HTML code that sets the color is the six digit hexadecimal value following the "#". This number is separated into three parts: red, green, and blue respectively (bgcolor="#RRGGBB"). Thus, the first two digits specify how much red is in the background, the second two digits specify how much green is in the background, and the last two digits specify how much blue is in the background. Hexadecimal has values ranging from 0 to 9 and then continues from A to F (10 to 15 in decimal). So the full range is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. There are 256 possible intensity values for red, green, or blue since 16 * 16 is 256. The lowest intensity for a color is "00" (none), and the highest intensity for a color is "FF" (all). These intensities are then combined to create one final color.
So, the example "#0000FF" would be blue since there is no red, no green, and all blue. Here are some other examples and their respective colors:

Hexadecimal Value

Color

000000

Black

FF0000

Red

00FF00

Green

0000FF

Blue

888888

Grey

FFFF00

Yellow

00D0FF

Light Blue

FFFFFF

White

 

 

Setting up your acme account for a web page

You are going to create your very own web page. To do this, you need to first set up a default web page. Do the following:

    1. Log on to acme
    2. Type: cd ~
    3. Type: mkdir public_html
    4. Type: chmod 755 public_html

What this did is create a directory called public_html in your home directory. The source for your web page will go in the file index.html you'll make this file.

 

Where is my web page?


Your web page will be at: where gtxxxxx is your gt-number

Where do I create HTML files?

Today, there are a number of software packages, such as Hot Dog, that capable of generating fancy web pages. However, since HTML is just plain text, it is perfectly fine to use pico, emacs, vi, or your favorite text editor to create and edit web pages.

Go ahead and use your favorite text editor to open up the index.html file in your public_html directory. You can see your modification if you simultaneously press the Shift key on your keyboard and click the Reload button in your web browser. Editing your web page by hand is probably the best way to get familiar with how HTML really works.

 

Creating your own web page

It is now time to create your web page. Below are a few important things you should know before you start, and the requirements you need to meet for grading purposes.

 

 

After you have finished creating your web page, do nothing! Yes, that's right. Because your web page is world-readable, we can look at and grade them without you using turnin.

A word of warning...

DO NOT TOUCH YOUR WEB PAGE AFTER THE "TURNIN" DEADLINE!!

We will be checking the dates on *all* of the files in your public_html directory. If the date on any file is later than the due time, you will get a zero!

That's it for now. Do not throw away your web page after we have graded it. You'll be modifying it in the second HTML lab.