Web Design Primer
Writing HTML (Basic)


Lesson 5: BACKGROUND & IMAGES

By now you know enough to write a very nice, text-based home page, but it is the ability of the World Wide Web to provide pictures, technically called images, graphics, or sometimes icons, that has made it so popular. In this Lesson, you'll learn how to place an image and change the background on your page and also how to turn an image into a link to another page.


Placing An Image On Your Page

The command to place an image is constant. You will use the same format every time.

Now might be a good time to talk about where to store everything because you're starting to call for additional items to fill up your home page. Until now, all you did was put text on the page. Now you're going to place an image.

At this point in your HTML career, it's a good idea for you to place whatever images you are going to use in the same place as your web pages. That means place the image right on the same floppy disc, or in the same hard drive directory, as the page that will call for it. There's more on that coming up in Lesson 7. But for now, just store everything together in the same place.

Here's the format for placing an image:

<IMG SRC="image.gif">

By replacing "image.gif" with "homepage.gif", you get this...

Here's What's Happening

 


Image Formats

There are four basic formats you will find on the World Wide Web. Each is denoted to the browser by a different suffix. Remember that "name.suffix" discussion from Lesson 1?


Where Do I Get Images For My Page?

They are literally everywhere. A lot of sites allows you access to over 500 images for free, and there are other sites out there that offer just as many. Plus, since you've been surfing, you've seen hundreds of images already. If you see something on someone's page that you really like, ask to use it. Don't just take it. That's not right and could be against copyright law. Ask. You'll probably get the image. In no time you'll have a slew to use on your page.

 


Activating An Image

Okay, this gets a little fancy. In Lesson 4, I showed you how to create a hypertext link. What it did was create blue words on your page so someone could click on them and then jump to another site. Well, here we're going to set it up so an image becomes clickable or "active." The viewer would click on the image, instead of on blue words, to make the hypertext link. I'll make a link to my home page using the image above.

Here's the format:

<A HREF="A:\MyHome.htm"><IMG SRC="homepage.gif"></A>

Look at it again. See what happened? I placed an image Tag where I would normally have placed words. Here's what you get with that format. Lay your pointer on the image, but don't click. You'll see the entire image is active:

Neat, huh? But what's with that new border around the image? That's what happens when you activate an image. It attempts to turn blue, or whatever color the page is set to, like the wording it's replacing, so it places what's known as a "border" around the image. Some people like it. I don't, and I know how to get rid of it.

To make the border disappear, you again turn to a trusty attribute, a command inside of a command.

Here's the format:

<IMG BORDER="0" SRC="homepage.gif">

See what I did? I added an attribute that denoted that the border should be 0. You can go the other way too if you'd like. Make it BORDER="55" if you want. It'll just make a huge border. Note that the number 0 is in quotes. It is an attribute, after all.

Here's what you get using BORDER="0":

Again, lay your pointer on the image without clicking. You'll see that it is active but doesn't carry that annoying blue border.


Background Colors

Changing background colors is very simple. You need two things:


1. The command for changing any background item is found within the page's BODY tag. To change just the background color, enter this attribute:

<BODY BGCOLOR="######">

2. Now you need a color code. This code is the same as we have discussed in the previous lesson (Manipulating text). The codes are not very user friendly and you need a chart to let you know what code makes what color so I've created a page showing some basic color codes. There are actually over a thousand hex codes producing every imaginable shade of red, or yellow, or whatever. You'll see what I mean. Look over the page... write down a couple of codes... and come on back to finish the lesson.

Welcome back. No doubt you looked around and saw a couple of colors. Neat, huh? Hopefully you brought back a color code (hex code) you'd like to use -- but if not, no matter -- I have one: "FFFFFF." That code will produce pure white. (Why FFFFFF?!) I told you the codes weren't too nice.

Be sure to enclose it all inside of quotation marks! So now that I know the code of the background I wish to create, I simply insert the code into the command and place the attribute on the page inside the <BODY> tag. The code for a white background will look like this:

<BODY BGCOLOR="#FFFFFF">

Please note: When you write these codes, you may notice I write them with a "#" sign in front of the code. It used to be that you had to do that but not any more. You may want to just use the six-digit code.


Background Wallpaper

The name is a bit misleading. When you see an HTML page with wallpaper or backgrounds, it is not one continuous .gif or .jpeg. It is one small .gif or .jpeg repeated again and again... and it is equally as simple as the colors above.

First you need a background image. 

Since you need a digitizer to make backgrounds, and I know not everyone has one of these at their fingertips, the best way to use a background is to grab one off the Internet. Here are a couple background images I have downloaded. Go on and check.

Welcome back. Now that you have a .gif or .jpeg for your background, you will want to put it in the same directory you place all your other images into.

Again, all background attributes come inside the <BODY> tag. Like so:

<BODY BACKGROUND="image.gif">

     All color commands are overridden by the BODY BACKGROUND command. That's mainly because the wallpaper goes over the color.

But... it will take a bit of time for the background .gif or .jpeg to load. It looks nice to put a color command before the BODY BACKGROUND command. What happens is that your page goes to a certain color and then the wallpaper wipes over that color. Nice effect.

Please note: The use of two commands, one for BGCOLOR and the other for BACKGROUND, does not work on upper level browsers. You'll need to put them both together in the same command. Something like this:

<BODY BGCOLOR="#FFFFFF" BACKGROUND="image.gif">

And that brings this lesson to a close. Next lesson you'll deal almost exclusively with attributes in order to manipulate your images. You'll truly impress your friends with this one.


Exercise 5: (to be submitted next meeting) This exercise is a must for you to make, you will not get your Certificate of COMPLETION without doing this exercise.

  1. Open the same file you have created from the last exercise in Lesson 4 (resume.html), or you may create a fresh one from your "notepad" or "simple text".
  2. Use <H1> or <H2> tag in your main Heading (e.g. RESUME, Curriculum Vitae)
  3. Use <H2> or <H3> tag in your sub-heading (e.g. Personal Info, Education, Work Experience, Skills, etc.). These are mostly your hotspots, remember the tags <A Name="____">...</A>?
  4. Use "bgcolor" and "background" attributes in your <BODY> tag (e.g. <BODY bgcolor="beige" background="image.gif">). You may use the background images I have included in this lesson but don't forget to save the image/s in your exercise diskette.
  5. Add photograph... you may add your own photograph  if you have one (pls. file size should not be more than 50KB) or you may use my own photograph (he he). Again, don't forget to save your photograph in the same diskette.
  6. Make it consistent, I mean use <B>, <I>, <FONT color....>, etc. consistently like below....
    Name: Firstname Lastname
    Nickname: Your Nickname
    Address: P.O.Box 12345, Dubai, United Arab Emirates
  7. Use hyperlink/s to go back to the top of your page. 
  8. You may use the graphics I have included in this diskette as you like.

Back to lessons

Copyright © 2000-2002, MT for use in HTML Writing Course at FWRC-OWWA Only. All rights reserved


Hosted by www.Geocities.ws

1