|
|
Building Web Pages From Ground Zero By Professor Nibble ã Nibble University 2000-2007 HyperJump to Images As Links , Using Anchors , Email Links , Comments , Backgrounds , Assignments CREATING LINKS, COMMENTS AND BACKGROUND - Lesson 8 |
|
|
Links From One Page To Another Without links there could be no World Wide Web. You could type in a URL (Uniform Resource Locator) address and go directly to a page, but you would have to type in another address to go anywhere else. Typing in an address every time you wanted to go to another page or web site would get old really fast! Let's start off with links from one page to another without leaving your web site. The tag looks like this: <A HREF="pagetwo.htm">text you click on</A> There must be some text between the two <A> </A> tags or the viewer would have nothing to click on. The text will be underlined and blue in color in most cases. The example above has the file "pagetwo.htm" located in the same directory as the current page. If you need to jump to a different directory you would type in the appropriate location. We talked about this in the lesson on placing images. As a reminder, here is one more example. If the page is located in the directory above the current one, you would type in - <A HREF="../pagetwo.htm">text you click on</A> To link to a page on a different web server, you must type in the entire URL (address). Example: <A HREF="http://www.cnn.com/index.htm">text you click on</A> This is called an absolute URL because it is an entire address. When the file you want to jump to is on your own server, it is best to use relative URLs. A relative URL is always in relation to the directory structure of your hard drive and where one file is in relation to the file you want to go to. When using relative URLs for all files located on your server, you can move your whole web site as a unit to another server and the links won't have to be re-typed. Many web site developers suggest you NOT use the words "Click Here" for a link label. Instead, use keywords that already exist in your text to identify the link. By the way, a link label is the word or words underlined and in blue (usually) that you click on. Example: Bad Way There are many good news stories on CNN. You should visit this great web site. Click Here to go there. Good Way There are many good news stories on CNN. You should visit this great web site. |
|
|
Jumping to a new web page is not always done by clicking on blue underlined text. Sometimes you click on an image - like an icon, clip art or photo. The tags for creating this type of link are simple. Just put a graphic tag where the text link label would go. Here is an example: <A HREF="pagetwo.htm"> <IMG SCR="dino.gif"> </A> When you click on the clip art of the dinosaur, you will go to the file - pagetwo.htm. Between the link tags <A HREF=" "> </A> you put an image tab rather than text. Sooooooo simple. As a reminder, our HTML code would be better written like this: <A HREF="pagetwo.htm"> <IMG SCR="dino.gif" ALT="Picture of a Dinosaur"> </A> In a previous lesson we mentioned you should always put ALT statements in your image tags. |
|
|
Have you ever jumped from one spot to another on a web page without leaving that particular web page? I'm sure you have. There are several anchors on this web page. To create links that jump from one position on a page to another you have to create an anchor. Microsoft WORD calls them bookmarks. A typical use of anchors is to jump from a Table of Contents at the top of your web page to various sections of your page. Every section should have a section heading. The section heading for what you are reading right now is called "Using Anchors". We need to place an anchor tag in front of the words "Using Anchors". Anchor tags are not visible to the viewer. Let's say our section heading in size 2. Therefore, to create an anchor right in front of it we would type this: <H2> <A Name="anchor">Using Anchors</H2> The tag for making an anchor is <A Name="name of anchor"> We have just created a spot on our page to jump too. We've given that spot a name - anchor. The name can be any word you want. If you use more than one word for your anchor name, you must be sure to place it in quotes. If you use a single word, you can drop the quotation marks. Creating the anchor is step one in a two step procedure. You must now create your link to the anchor - step 2. Go to the word or words (or image) that will be the link label. Put link tags around it. However, instead of using a file name or URL absolute address, put in a # sign followed by your anchor name. At the top of this page I have some HyperJumps, which is just a modern way of saying Table of Contents. The words Using Anchors have been turned into a link that jumps to an anchor called anchor. The link looks like this: <A HREF=#anchor>Using Anchors</A> The link on Images As Links looks like this: <A HREF=#images>Images As Links</A> The anchor name I chose for jumping to the section on images as links is images. Now you have enough info to become a "jumpin fool". Emphasis on FOOL. There is much more to learn. Like: What would you do if you wanted to link to a file called pagetwo.htm, but you want to jump to somewhere in the middle of the page rather than the top? Let's say the heading for pagetwo.htm is Countries I've Visited. There are several sections on this page - each section has a heading. Each heading is the name of one of the countries I've visited. Half way through the page is the section on Malaysia. My HTML coding would look like this: You may want to go to my Countries I've Visited page to read more information about <A HREF="pagetwo.htm#malaysia">Malaysia</A>or other Asian countries. The above example would be on the page I'm jumping from. My link would be the word "Malaysia". If someone clicked on Malaysia they would go to the file called pagetwo.htm, but not to the top of the page. They would go to the anchor I created (called Malaysia) just before the section on Malaysia. Don't forget you must have defined an anchor name in which to jump too. When we learn how to create FRAMES, you will need to learn how to link to specific frames or your page may be loaded into places you don't want. There's nothing worse than having a full size page load into a skinny two inch left frame. Well, maybe there is. Have you ever tried to eat vanilla ice cream without chocolate topping? |
|
|
You can create links to other places besides web pages. You could go to an FTP site, a Gopher site, a newsgroup, a telnet site, or an email address. Linking to an email address is used quite often. I've never really linked to any of the other places. I'd have to pull out my HTML manual and look at the appropriate code. If you ever have the occasion of linking to one of the above places, pull out your HTML book. However, I will equip you with the knowledge to make an email link. You knew I would, since I made an anchor to this section from the HyperJump. It's easy: <A HREF="mailto:harrysmidlap@hotmail.com"> Email Me </A> Need I say more? There are some more advanced features of linking. We might get into some of them later, but for now, you have enough information to do a great deal. I think I may attempt to teach you how to make an image map later on. Basically, an image map is a picture with several hot spots (links) on it. For instance, you could have a map of the USA with 50 links taking you to state pages. Point your cursor to a state and click and hold on to your hat Dorothy. |
|
|
Comments are used to insert information into your source code that will be ignored by a browser. It is used primarily for helping explain what your source code is all about. It can also be used to put in information such as who wrote the code for the web page, etc. Any time your source code is so difficult that you may forget what you were doing, or what is where, it is a good idea to include some comments. When you welcome others to go over your source code to see how you did something, it is common courtesy to include comments to help explain the method of your madness. I think comments are very useful when you have a page that is often up-dated. They help you quickly find various parts of your code, make the changes and get on with your life. I think I will have you include comments to describe who created the page, what class you are in, and what grade. We'll start this with Assignment 2 of this lesson. Here's how to make a comment: <!--This is the comment.--> You open the comment with a less than sign followd by an exclamation point and two dashes. You close the comment with two dashes and a greater than sign. Your comments may be several lines in length or just one. All you have to remember is to open and close it with the proper tag. |
|
|
Ask your teacher for the data for Assignment 1 Lesson 8. You will be given a biography on Captain James Cook written by Nate Kerl. This biography is divided up into four sections.
|
|
|
|
|
|
In this assignment you are going to practice creating links to other HTML web pages and using the background attribute. I'm going to allow you some room to be a little creative for this assignment. As long as you follow the guidelines below and include all the required components, I'm sure you'll do great. Include appropriate information between the title tags of each page and 3 comment lines. One for your full name, one for your class (Grade 9, Multimedia, etc.) and one for your class period (2nd Period).
|