Inline Images

The "Image" Tag

The use of images on the World Wide Web is rampant, with .gif and .jpg files being used for everything from personal Web pages to banner ads on commercial sites. This particular tag is also one of the more difficult tags to use, both because of the number of attributes and options and because aligning text with images can often be very difficult. We'll take a good look at the tag, but we'll put off some of the options for later in the tutorial. After all, at this point, you just want the image to show up on your page, right?

<IMG ALIGN="value" ALT="alternate text" BORDER=# HEIGHT=# HSPACE=# LOWSRC="URL" SRC="URL"
�UNITS="unit type" WIDTH=# VSPACE=# ISMAP="server map URL" USEMAP="client map URL">

Although you may hear otherwise, the only required attribute of the <IMG> tag is SRC.

Examples of Image Alignment

Some of the ALIGN values may be a little bit difficult to understand without seeing them in action. Hence, here are some examples of image alignment in relation to text. The text lines were specifically broken in places to show how multi-line text will relate to the image. The examples will also show the image tag placed before the text and in the middle of the text.


This text in your HTML file: results in this:
<IMG SRC="./rose.gif" ALIGN="TOP">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="TOP"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="MIDDLE">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="MIDDLE"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="BOTTOM">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="BOTTOM"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="LEFT">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC=".rose.gif" ALIGN="LEFT"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="RIGHT">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="RIGHT"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="TEXTTOP"> Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="TEXTTOP"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="ABSMIDDLE">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="ABSMIDDLE"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="BASELINE">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="BASELINE"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
<IMG SRC="./rose.gif" ALIGN="ABSBOTTOM">Here is some sample text.

This is after a line break.
Here is some sample text.
This is after a line break.
Here is some <IMG SRC="./rose.gif" ALIGN="ABSBOTTOM"> sample text.

This is after a line break.
Here is some sample text.
This is after a line break.

Using an Image as a Link

On the previous page, I made a point to have "Content" placed between the opening and closing tag of an anchor. This is so that you can arrange for images to be the actual links to other pages. If you and your friends design web pages for fun, have people browsing your site click on images of your friends to go to their sites, rather than just textual links.

The format is the same as a regular anchor, with an image tag put in place of text, like so:

<A HREF="#TopAnchor"><IMG SRC="./happy.gif"></A>

Simple, huh?

Using an Image as Background Wallpaper

The <BODY> tag allows the use of an image for your background, rather than just a solid color. Find an image -- any format that your browser may display -- and prep it for use on the page. This may mean that you will need to trim the image to a smaller size, and may mean that you will need to use an image editor to make it a lighter color so your other context will be visible.

The image will be tiled in the background, and will overlay any "BGCOLOR" setting that you may have set. The format of the <BODY> tag now looks like this:

<BODY BACKGROUND="./pink_fabric.gif">

and the result looks like this.


Next, some basic table creation and manipulation, so you can do the things I've been doing throughout this tutorial. It will give you the basic syntax for a table, but not all the bells and whistles (that's for later!).