This tutorial was just put together by me today, it's not much, but I hope it will at least help a couple of people who are new to HTML. If you have any suggestions or questions about it, feel free to post them in this topic.
Note: due to the forum's restriction on the amount of images allowed in a single post, the tutorial is split into four posts in this topic.
This tutorial is split among four sections in this post. This is how the tutorial is organized:
- Introduction to images on the web
- Rollovers
- Preloading and images in text
- Image maps
1. Introduction to images on the web
Images are used on every web page on the net. They are used as logos, icons, screenshots, and more. Images add to the look and feel of every web site. This tutorial will cover how to place images on a web page, how to links images, and ways you can customize your pictures. So let's get started.
There are a couple of different types of images that you can display on a web page. Here are the most common types:
.gif - Graphics Interchange Format
.jpeg and .jpg - Joint Photographic Experts Group
.png - Portable Network Graphics
For this tutorial, we will use this image

.
Here is how you display an image:
Code:
<img src="http://talkwebdev.com/images/statusicon/forum_new.gif" />
Now if you are wondering, "What is happening here?" here is how it works:
img is the tag. It tells the browser that you are requesting an image to be displayed on the web page. The image will appear wherever you place your tag.
src is the attribute that tells the <img> tag which image to show. In this case, the image we want is
http://talkwebdev.com/images/statusicon/forum_new.gif, so we place that inside the quotes.
If you use the code above, for any image, it will display the image exactly as it is. There will be no changes made to it. But let's try and make some changes to it. Below are some attributes for the <img> tag to make your image look different.
Attributes for the <img> tag
alt - This is the alternate text attribute of an image, and is a required attribute. If an image does not appear, or a user has disabled images, this is the text that will appear in place of that image.
title - Text that is displayed as a tooltip when the user moves his or her cursor over the image
width - The width attribute tells how wide the image should be displayed (in pixels). However, you can also use a percentage to tell it to take up that much of the percentage of the screen. If you used width="100%", the image will automatically be as wide as the user's screen, no matter what.
height - Tells how tall the image should be displayed (in pixels). You can also use a percentage for this as well.
Now let's try some of these out.
Code:
<img src="http://talkwebdev.com/images/statusicon/forum_new.gif" width="100" height="150" alt="New Posts" title="This is an image" />
Our image is now much bigger since we specified height and width. Also, if you try put your mouse over the image for a second, a text box will appear with "This is an image" in it.
Note: To settle any confusion about the "alt" attribute, it is not what is supposed to be used for tooltip text. That functionality is reserved for the "title" attribute, which is a core attribute that can be used on almost any HTML tag.
Note: It is always good to specify the width and height of an image. It shortens loading time because the browser does not have to "find out" what the width and height are for the image, it is already specified. But be careful about specifying width and height because, as you can see in our example, altering the width and height of an image from the original may cause the image to become unproportional or will decrease the quality if you make the image larger.
Now that we know how to create an image and modify it, let's link it. We will use the same image we used before. You link images the same way you would with text, with the <a> tag and the
href attribute. Here is how we would do it in HTML:
Code:
<a href="http://talkwebdev.com/">
<img src="http://talkwebdev.com/images/statusicon/forum_new.gif" /></a>
What this is doing is making it so the user can click on the image and it will bring us to this page:
http://talkwebdev.com. We place what we want linked after the <a> tag. Then we place the </a> tag to declare when we want it to stop linking to a page.
You'll probably notice a border around the image even though we did not specify for there to be one. This is because, by default on certain browsers, an image will have a border around it if it is linked. We can get rid of this border by specifying the border to be 0 pixels in the style attribute:
Code:
<a href="http://talkwebdev.com">
<img src="http://talkwebdev.com/images/statusicon/forum_new.gif" style="border: 0px" /></a>
Note: we are not using the border attribute because it's depreciated.