Chapter 3 - Part 1 - Lecture Notes:

Color Sites for Reference



The Color HEX Code



The six-digit number and letter combinations represent colors by giving their RGB (red, green, blue) value. RGB triplet RRGGBB where RR= Red GG= Green and BB= Blue. The six digits are actually three two-digit numbers in sequence, representing the amount of red, green, or blue as a hexadecimal value in the range 00-FF. For example, 000000 is black (no color at all), FF0000 is bright red, 0000FF is bright blue, and FFFFFF is white (fully saturated with all three colors).


The Background Attribute


CONTROLLING DOCUMENT BACKGROUNDS

Some of the following information was taken from the Netscape Page at http://home.netscape.com/assist/net_sites/bg/

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.


THE BGCOLOR ATTRIBUTE

To change the color of the background without having to specify a separate image that requires another network access to load. This attribute allows just that. Coded as below:

<BODY BGCOLOR="#rrggbb">Document here</BODY>

Where "#rrggbb" is a hexadecimal red-green-blue triplet used to specify the background color.


HOW TO CONTROL THE DOCUMENT'S FOREGROUND

Once you have the background color or image set, you are going to need to control the foreground to establish the proper contrasts. The following attributes are also recognized as part of the BODY tag.
 

THE TEXT ATTRIBUTE

This attribute is used to control the color of all the normal text in the document. This basically consists of all text that is not specially colored to indicate a link. The format of TEXT is the same as that of BGCOLOR.

<BODY TEXT="#rrggbb">Document here</BODY>
 

THE LINK, VLINK, AND ALINK ATTRIBUTE

These attributes control the coloring of link text. VLINK stands for visited link, and ALINK stands for active link. The default coloring of these is: LINK=blue, VLINK=purple, and ALINK=red. Remember you can use the hex code for the color as well as word colors. Again the format for these attributes is the same as that for BGCOLOR and TEXT.

<BODY LINK="#rrggbb" VLINK="#rrggbb" ALINK="#rrggbb">Document here</BODY>


COMPLETE EXAMPLE

<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>


Images


http://www.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimerAll.html

 


Inline Images

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.
 


Aligning Images

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.

Alignment and code
Example
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.

[HOTLIST] 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


Alternate Text for Images

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.


Images as Hyperlinks

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>


Borders

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]">
 

Code
Results
<a href=under.html><img border=3 src=coffeecup.jpg></a>
<a href=under.html><img border=0 src=coffeecup.jpg></a>A link to somewhere (no border) A link to somewhere (no border)
<a href=under.html><img border=5 src=coffeecup.jpg> </a>A link to somewhere else (border 5) A link to somewhere else (border 5)