HTML 3.0 spec. have added a BACKGROUND attribute to the BODY tag. The purpose of this attribute is to specify a URL pointing to an image that is to be used as a background for the document. In Netscape 1.1, this background image is used to tile the full background of the document-viewing area. Thus specifying:
<BODY BACKGROUND="metal/brushed_aluminum.gif">Document here</BODY>
would cause whatever text, images, etc. appeared in that document to be placed on a background similar to this one.
<BODY BGCOLOR="#rrggbb">Document here</BODY>
Where "#rrggbb" is a hexadecimal red-green-blue triplet used to specify the background color.
<BODY TEXT="#rrggbb">Document here</BODY>
<BODY LINK="#rrggbb" VLINK="#rrggbb" ALINK="#rrggbb">Document here</BODY>
<HTML>
<HEAD>
<TITLE>Color Control Example</TITLE>
</HEAD>
<BODY BGCOLOR="#000000" TEXT="#F0F0F0"
LINK="#FFFF00" VLINK="#22AA22" ALINK="#0077FF">
This is an example document. Text is light-gray on black, and
<a href="nowhere.html">anchors</a> are yellow at first,
flashing blue-green when activated, and pale green if already visited.
</P>
</BODY>
</HTML>
Most Web browsers can display inline images (that is, images next to text) that are in X Bitmap (XBM), GIF, or JPEG format. Other image formats are also being incorporated into Web browsers [e.g., the Portable Network Graphic (PNG) format]. Each image takes additional time to download and slows down the initial display of a document. Carefully select your images and the number of images in a document.
To include an inline image, enter:
<IMG SRC=ImageName>
where ImageName is the URL of the image file.
The syntax for <IMG SRC> URLs is identical to that used in an anchor HREF. If the image file is a GIF file, then the filename part of ImageName must end with .gif. Filenames of X Bitmap images must end with .xbm; JPEG image files must end with .jpg or .jpeg; and Portable Network Graphic files must end with .png.
Image Size Attributes
You should include two other attributes on <IMG> tags to tell your browser the size of the images it is downloading with the text. The HEIGHT and WIDTH attributes let your browser set aside the appropriate space (in pixels) for the images as it downloads the rest of the file. (You can get the pixel size from your image-processing software, such as Adobe Photoshop. Some browsers will
also display the dimensions of an image file in the title bar if the image is viewed by itself without an enclosing HTML document.)
For example, to include a self portrait image in a file along with the portrait's dimensions, enter:
<IMG SRC=SelfPortrait.gif HEIGHT=100 WIDTH=65>
NOTE: Some browsers use the HEIGHT and WIDTH attributes to stretch or shrink an image to fit into the allotted space when the image does not exactly match the attribute numbers. Not all browser developers think stretching/shrinking is a good idea, so don't plan on your readers having access
to this feature. Check your dimensions and use the
correct ones.
You have some flexibility when displaying images. You can have images separated from text and aligned to the left or right or centered. Or you can have an image aligned with text. Try several possibilities to see how your information looks best.
Aligning Text with an Image
By default the bottom of an image is aligned with the following text, as shown in this paragraph. You can align images to the top or center of a paragraph using the ALIGN= attributes TOP and CENTER.
|
|
|
| Text aligned with the top
of the image
<IMG SRC ="http://www.cerritos.edu/hohly/online75/coffeecup.jpg" ALT="[HOTLIST]" Align=Top> Notice how the browser aligns only one line and then jumps to the bottom of the image for the rest of the text. |
This is an example of
text which can be aligned with your image. |
| Text is centered on the image
<IMG SRC = "coffeecup.jpg" Align=Center> Only one line of text is centered; the rest is below the image. |
This is an example of
text which can be aligned with your image. |
| Text is aligned Text top
<img align=texttop src="coffeecup.jpg"> |
This is an example of
text which can be aligned with your image. |
| Text is aligned middle
<img align=middle src=coffeecup.jpg> |
This is an example of
text which can be aligned with your image. |
| Text is aligned Absolute
middle
<img align=absmiddle src=coffeecup.jpg> |
This is an example of
text which can be aligned with your image. |
| Text is aligned bottom
<img align=bottom src=coffeecup.jpg> |
This is an example of
text which can be aligned with your image. |
| Text is aligned Baseline
<img align=baseline src=coffeecup.jpg> |
This is an example of
text which can be aligned with your image. |
| Text is aligned Absolute
bottom
<img align=absbottom src=coffeecup.jpg> |
This is an example of
text which can be aligned with your image. |
| <img align=left src=coffeecup.jpg>
Text to the left. |
The coffee cup you see in this example should be
seen with the text to the left. |
| <img align=right src=coffeecup.jpg>
Text to the right. |
The coffee cup you see in this example should be
seen with the text to the right. |
| For examples of text wrap
around an image are available at the following URL.
http://www.cerritos.edu/~WOOLEVER/imgspace.html |
http://www.cerritos.edu/~WOOLEVER/imgspace.html |
Some World Wide Web browsers -- primarily the text-only browsers such as Lynx -- cannot display images. Some users turn off image loading even if their software can display images (especially if they are using a modem or have a slow connection). HTML provides a mechanism to tell readers what they are missing on your pages if they can't load images.
The ALT attribute lets you specify text to be displayed instead of an image. For example:
<IMG SRC="UpArrow.gif" ALT="Up">
where UpArrow.gif is the picture of an upward pointing arrow. With graphics-capable viewers that have image-loading turned on, you see the up arrow graphic. With a text-only browser or if image-loading is turned off, the word Up is shown in your window in place of the image.
You should try to include alternate text for each image you use in your document, which is a courtesy for your readers -- or, for users who might be visually impaired, a necessity.
Inline images can be used as hyperlinks just like plain text. The following HTML code:
<A HREF="hotlist.html"><IMG SRC="BarHotlist.gif" ALT="[HOTLIST]"></A>
(Note that this link doesn't actually go anywhere.) The blue border that surrounds the image indicates that it's a clickable hyperlink. You may not always want this border to be displayed, though. In this case you can use the BORDER attribute of the IMG tag to make the image appear as normal. Adding the BORDER attribute and setting it to zero:
<A HREF="hotlist.html"><IMG SRC="BarHotlist.gif" BORDER=0 ALT="[HOTLIST]"></A>
The BORDER attribute can also be set to non-zero values, whether or not the image is used as a hyperlink. In this case, the border will appear using the default text color for the web page. For instance, if you wanted to give your image a plain black border to help it stand out on the page, you might try this:
<IMG SRC="BarHotlist.gif" BORDER=6 ALT="[HOTLIST]">