IRC

Instructional Resource Center

 

 

Beginning HTML

1) Prerequisite

In order to fully participate in this workshop, you must be able to:

    • Windows Prereq's:
      • Save a file to a specific directory/folder using the "file/save as ..." process
      • Create a directory/folder during the file save as process
      • Comfortably move between multiple application windows using the task bar at the bottom of your screen
      • Find files on your computer using the Find tool
      • Open a program using the start menu

If you do not know something listed above, we strongly suggest that you sign up for the prerequisite workshops before taking this workshop.

2) Workshop Objective

At the end of this workshop, you will be able to:

  1. Create an HTML page with the following included:
    1. text formatting
    2. links
    3. graphics
  2. Use Notepad
  3. Switch between applications
  4. Preview a web page in a browser

<back to top>

3) Getting started with HTML

What is HTML?

HTML = HyperText Markup Language

HTML tells the browser how to structure the content of a web page, and allows people to share documents across different platforms. It works on any kind of computer with a browser, whether it be a PC, Mac, Linux, or another operating system.

HTML coding can tell your web browser what a piece of information is -- a paragraph or a primary heading, for example -- or how a piece of information should look -- bold text or a lime green background, for example.

We'll use a few key terms to talk about HTML:

Tag
A tag is the thing in angle brackets. There are open tags and close tags. Frequently we call the open tag simply "tag" and the close tag "end tag". A paragraph would look like this: <p>Here is the text of my paragraph.</p>
Note: the tag is not case sensitive, so you can have either <p> or <P>.
Attribute
An attribute is the thing within the tag that has an equal sign and quote marks. It appears only in the open tag. Adding an attribute to our paragraph tag would make it look like this: <p align="center">Here is the text of my paragraph.</p>
Element
An element is the concept or piece of information marked by the tag. For our example, the element is the text of the paragraph itself.

So, if we were to draw an analogy with the English language, we can think of a tag as a noun, and an attribute as an adjective modifying the noun.

All of our pages will begin with the tag <html>, and end with the tag </html>.They will also all have a section that gives information about the document, known as meta-data, within the tags <head> and </head>. The main portion of the document, the part that your viewers will see, will be contained in the tags <body> and </body>.

<back to top>

4) Exercise 1 - Create a page

Follow these steps to create a Web page:

Use Spacing:

No matter how many times you hit "return," it will not show up in the browser. Carriage returns, tabs, and extra spaces will not affect your HTML, so use them to make your HTML file easier to read.
And if you add several spaces, they are all collapsed into one single space.

  1. Open a simple text editor, such as Windows Notepad.
  2. Type in the following tags:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>
    Look familiar? These are the six tags you will always include in your web pages.
  3. Insert the tags <title> and </title> between the <head> tag and the </head> tag.
  4. Between the title tags, type "My Name". This will be the title of the document you create.
  5. Between the body tags, type your name.
  6. Save the file as index.html.

    Naming files:

    Do not use spaces or special characters (other than the hyphen or underbar). Use all lower case characters in your file name. These few rules will simplify life later on.

  7. Open your browser, and select File, Open and type in the path for the document you just saved.

Congratulations! You have just created an HTML file.

What happened to the text "My Name" that was typed between the title tags?

Look in the title bar of your browser. Text between the tags displays up there, not on the page your user views in the browser window. It acts as an aid to your users if they become confused about where they are.

<back to top>

5) Containers

While we could toss all our information directly between the <body> and </body> tags, it wouldn't look very nice. Instead, we put all of our information into a series of other tags, within the body tags.

Think of the body element as a huge box, which contains many other boxes. Some of those other boxes contain goodies (our text), and some of them contain other boxes. In programming terms, this is called nesting. And just like closing the lids to all those boxes, your tags will have to close in a certain order. Imagine trying to put the lid on a smaller box after you put the lid on the larger box containing it -- it doesn't work.

So what are some of the containers we can put in the body of our page?
Paragraph - <p>
Heading - <h1>, <h2>, <h3>, <h4>, <h5>, <h6> The number gives the relative importance of the heading to the document, with <h1> as the most important. Do not choose your heading based on the way it displays in the browser. The display can be changed. Choose the heading according to the structure of your document.
Table - <table> This tag requires other tags within it in order to create a proper table, and is a bit more advanced than this course.
Ordered (numerical) list - <ol> containing list items - <li>
Unordered (bulleted) list - <ul>, also containing list items - <li>

Here is a coding sample of the body portion of our file after we add a couple of container tags:

<body>
<h1>Dana Doe</h1>
<p>Dana Doe lives in the town Anywhere, and often gets frustrated when people don't believe that it is really Dana's address.</p>
</body>

<back to top>

6) Exercise 2 - Containers

  1. Open the document you created in Exercise 1.
  2. Place the tag <h1> before your name, and the tag </h1> after your name.
  3. Add a paragraph with your address, using <p> </p> as a container, and using <br> to create line breaks in the paragraph.
  4. Add an ordered list with your three favorite web sites, using <ol> </ol> as your primary container, and <li> </li> as a container for each item on the list.
  5. Add an unordered list with the last three movies you saw, using <ul> </ul> as your primary container, and <li> </li> as a container for each item on the list.
  6. Save your document.
  7. Preview in the browser.

<back to top>

7) Formatting - Typography

Presenting text that is both legible and readible is important if you want viewers to actually read something on your web site. Bad typography will distract your viewers or completely turn them off. Good typography will grab their attention. It will also help viewers find their way around your page and prioritize your information.

Two Styles

There are two major font styles: serif and sans serif. An example of serif would be Times New Roman or Garamond. An example of sans serif would be Arial or Helvetica.

Serif         Sans Serif

Standard Fonts

Fonts faces are selected by placing font tags around the text:

<font face="Verdana">This font is Verdana</font>
displays as
This font is Verdana

This font will only show up as Verdana if you have Verdana installed on your computer (which thanks to Microsoft most of you do).

Sizes

There are very limited font size specifications in HTML. Sizes can be expressed by an absolute number from 1 (smallest) to 7 (biggest) or by a relative number such as +1 (one size bigger than the default) or -1 (one size smaller than the default).

The default setting for a paragraph on a browser is 3. To change that, use the size attribute of the font tag. <font size="2"> or <font size="-1"> which essentially do the same thing. Here are a couple of examples, the first with a serif font, and the second with sans serif:

<font size="2" face="Times New Roman,Georgia,Times">This is small -- set a font size 2.</font>
<font size="1" face="Times New Roman,Georgia,Times">This is smaller -- set at font size 1</font>.

<font size="2" face="Verdana,Arial,Helvetica">This is small -- set a font size 2</font>
<font size="1" face="Verdana,Arial,Helvetica">This is smaller -- set at font size 1</font>

Sizing is not the same on Macs and PCs. Macs using Netscape 4.7 or older or pre-IE5 browers see text smaller. So do not use a text size smaller than 2 (or -1) if you like Mac people.

Please note: if you want more control over your text, look at using Cascading Style Sheets to control your text. They also make changing your mind a lot easier, as there is one place to change the display, rather than all over your web site.

Physical Styles

Bold tags, <b> </b> are placed around text for emphasis or to create headlines

Italics can be specified by placing tags <i> </i> around text. Italics are common in the print world, used for titles, emphais, quotes, etc. However, italic text is hard to read on the web, particularly at smaller sizes, so use it sparingly. It is recommended to use other textual styles such as bold or a color changes instead of italics for any large amount of text.

You can designate text to be underlined by using the <u> </u> tags. While underlines are often used in the print medium, avoid underlined text for the web! Underlines mean "hyperlink" in the web world.

Logical Styles

You can designate your headings as headings using <h> tags. For example:

<h3>This is a heading</h3>

<h4>This is a subheading</h4>

Headings are a logical style, meaning that they say what the text is used for, and while they do effect text formating, this is not specifically why they are used. They provide important structural information to text readers and some search engines. As we adopt CSS and as search engines get better, heading tags will be more important helping to distinguish levels and importance of information. Therefore it is essential to use <h> tags only for headings and not for general text.

<back to top>

8) Formatting - Colors

Often colors do not look the same on a Mac as on a PC (Macs are lighter). Users with older computers also run into problems. There is something called a web safe pallette. The web safe pallette is 216 colors that are shared between Macs and PCs.

Colors may be specified by name, which may not give the same exact shade from browser to browser, or by a code known as the hexidecimal value. The hexidecimal value begins with a # symbol, and contains three sets of two numbers or letters. Web safe colors will contain three pairs of the values FF, CC, 00, 33, 66, 99 - white for example is #FFFFFF, navy blue is #000099.

We can use color in many different places to change the appearance of our site. Here are a few of the most important places we can use color:

  • page background
  • font
  • table background (used with more advanced HTML)
  • table border (used with more advanced HTML)

Use the attribute "bgcolor" in the <body> tag if you would like to change the background color in your file from the default, white, to another shade. Remember that it is very difficult for users to read a lot of text which displays on a dark background.

We can change the color of the type by using the "color" attribute in the <font> tag. This enables us to choose the best color to contrast with our background, and set the tone for the page.

<back to top>

9) Exercise 3 - Formatting

Let's change the formatting of our page.

  1. Open the document you used in Exercise 2.
  2. Change the appearance of your name by using the attributes "face" and "color" within the <font> </font> tags.
  3. Save, and preview in your browser.
    Note: if you do not see the changes, check the order of your tags, and try again. You may get a different effect if you have
    <h1><font face="verdana" color="green">My Name</font></h1> or
    <font face="verdana" color="green"><h1>My Name</h1></font>
  4. Change the background color of your page using the "bgcolor" attribute on the <body> tag.
  5. Change the size of some of the text on your page using the "size" attribute of the <font> tag.
  6. Save the file and preview in the browser.

<back to top>

10) Linking

In order to connect our page with other pages on the Internet, we need to create links. With links we can create a structure for our web site by determining which pages users can visit at a given point.

In HTML we use the anchor tag to create links. The information about where to go is stored in the attribute "href". It can be an absolute URL (http://...), which is used to create links to other people's Web sites or it may be a relative URL (file name or directory/file name), which is used to create links within our own site.

There is one other kind of link, called an e-mail link. It too uses the "href" attribute in the <a> tag, and looks like this: <a href="mailto:myaddress@gmu.edu">.

<back to top>

11) Exercise 4 - Linking

Let's try linking pages.

  1. Open your text editor and start a new HTML document.
  2. Between the <title> and </title> tags, type "Links Page".
  3. Add an <h1> heading to the body reading: "My Links Page".
  4. Add the following after the heading:
    <p><a href="http://www.gunstonhall.org">Gunston Hall Plantation</a></p>
    <p><a href="name.html">Back to My Name</a></p>
  5. Save the file as links.html in the same directory where you saved name.html from Exercise 1.
  6. Open your browser, and select File, Open and type in the path for the document you just saved.

You should see blue underlined text. Click on "Gunston Hall Plantation". Does it work? If not, check your code to be sure you didn't make any typing mistakes. Check the link to your name page as well.

Try adding links to your name page for your favorite web sites and an e-mail link, then test them out.

<back to top>

12) Getting Images

Images are essential to web design, bringing web pages to life, providing interest and variety, allowing branding, and presenting information that cannot be easily conveyed with text.

Images can come from a variety of sources: a digital camera, a scanner, a drawing from a graphics program, or one of the many free or commercial sources for images. If you find an interesting image on one of the many Web sites with free graphics, keep the extension it suggests as you save the file, otherwise you will have a problem with the image.

There are workshops available to teach you about scanning, using graphics programs, and digital cameras. Visit http://ittraining.gmu.edu to find the schedule and workshop descriptions.

<back to top>

13) Exercise 5 - Getting an Image

  1. Right click on the image below.
  2. Save the image to the directory with your class work. Call the file the name suggested in the dialogue box, gmu-logo2.gif.
  3. Check the image properties by right clicking again, this time selecting Properties. Note the width and height of the image, we'll use that when we insert the image.

gmu logo

<back to top>

14) Inserting Images

Images are one of the few examples of "empty" elements in HTML. There won't be a set of begin and end tags with data in between. Instead, there is simply the <img> tag, with many attributes in the tag used to specify the image location, its dimensions, alternate text description for those who can't view it, where it should align, and whether it should have a border or not. Here are some of the basic attributes we need:

  • SRC - Provides the location of the image file. As with links, the location may be expressed either as a relative URL or as an absolute URL. As you develop your projects, you will want to use a relative URL.
  • ALT - Provides text which displays on browsers that cannot display images, have images turned off, or is read by a machine reader for blind users. Some browsers display this text when the mouse moves over the image, and search engines may use it to find your information. Use a good, short description in this attribute.
  • WIDTH - Provides the width (across the screen) of the image to be displayed. Values may be displayed in pixels or percentages, but only an accurate pixel size will avoid distortion.
  • HEIGHT - Provides the height (down the screen) of the image to be displayed. Again, values may be displayed in pixels or percentages, but only an accurate pixel size will avoid distortion.
  • BORDER - Indicates the size of a border for the image in pixels. For no border, set the value to "0". If you surround your iamge with an anchor to create a link, set the value to "0" to avoid a blue border around the image.
  • ALIGN - Indicates the proper alignment for the image Text will wrap according to the alignment and placement of the image. There is a legal list of values for this attribute, "LEFT" and "RIGHT" are perhaps the most useful values.

<back to top>

15) Exercise 6 - Inserting an Image

  1. Open the document you created in Exercise 1.
  2. Between the body tags add:
    <IMG SRC="gmu-logo2.gif" ALT="George Mason University" WIDTH="100" HEIGHT="28" BORDER="0">
  3. Save the file and view in your browser. The image should display. If not, double check your code for typos, and check that the HTML file and the image file are in the same directory.
  4. Next, add a few paragraphs of text above the image, and a few paragraphs of text below the image. We are going to test where things move when we place images and text together.
  5. In the image tag, add:
    ALIGN="right"
  6. Save, and view.
  7. Replace the value "right" with "left", save and view.

<back to top>