Let's get into putting images into a web page. We're going to use this one. Right click to save it off this page. Save it as chef.gif to the same directory you previously saved page1.html.

chef.gif

You specify an image with the <img> tag...

<body>
<img>
</body>

We must also specify the source and the size.

<body>
<img src="chef.gif" width="130" height="101">
</body>

FAQ: How do I find out the width and height of an image?

A: Well, there are a couple different ways. One way is to load it in a graphics viewer. An outstanding (and free) viewer that I use is Irfan View.

Another very popular graphics editor is Paint Shop Pro. It's is time limited shareware but it is one fine editor. If you goYou'll find there an older version that I VERY highly recommend for beginning web designers.

Another method is to use a text or html editor that imports the size when you insert the image. I use NoteTab, and an image tag of my design is built for me when I simply drag the filename on to the current file. I can insert an image in about 6 tenths of a second :-) I told you NoteTab was my favorite!

Let me make the point that not only does the source specify what image, it also specifies where is the image. The above source, src="chef.gif", means that the browser will look for the image named chef.gif in the same folder (or directory) as the html document itself. Below are a few diagrams...

src="chef.gif" means that the image is in the same folder as the html document that called for it.
src="images/chef.gif" means that the image is one folder down from the html document that called for it. This can go on down as many layers as necessary.
src="../chef.gif" means that the image is in one folder up from the html document that called for it.
src="../../chef.gif" means that the image is two folders up from the html document that called for it.
src="../images/chef.gif" means that the image is one folder up and then another folder down in the images directory.
src="../../../other/images/chef.gif" I'm not even going to try and put this into words. I hope you get the drift.

There is another way that this can be done. All references to images can have as their source the complete URL. For example:

http://www.yourdomain.net/LottzaStuff/images/chef.gif

Why, you ask, does it make so much more sense to use relative (partial) URLs as opposed to absolute (complete) URLs?? Because you can build your site locally and all the links will work. When your pages are done, you just upload the whole pile to your server and everything will work just fine. In addition, it is easier for the browser to get the images and your page will load faster.

Is there ever a reason to use an absolute URL? Sure, if the image resides on a completely different server.


<< BACK NEXT >>
So, you want to make a Web Page!
Lessons: Intro 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Index & Quick Reference      Table of Contents      ColorPicker      BareBones HTML Guide
Color Charts      Simple Font Widget      Practice Exercises      Where are my images?
Print version of this tutorial available - Get the PageTutor Book & CD

kslokesh - All Copyrights, Trademarks, Logos etc. belong to their respective owners.
www.kslokesh.com