Stuart Moulthrop & Nancy Kaplan
University of Baltimore
School of Information Arts and Technologies · Revised 2008


Part 3: Color and Graphics


3.1 | ADDING COLOR TO WEB PAGES


3.1.1 · In the <BODY> Tag 3.1.2 · BGCOLOR in the <TD> Tag (Tables)
In the 2.0 release of Internet Explorer (early 1996) Microsoft implemented custom background colors in the cells (<TD>) of HTML tables; see the notes for Part 4 for details. Netscape incorporated this feature in Navigator 3.0; now both browsers allow BGCOLOR as an attribute for <TD> in tables, letting authors color table cell backgrounds individually.
3.1.3 · Applied to a Short Span of Text
Before HTML 4.0, specifying that a short span of text be displayed in a particular color or size required a <FONT></FONT> container with COLOR and/or SIZE attributes. HTML 4.0 accomplishes these effects through style rules. These rules can either be specified as values for a STYLE attribute in some tag (for example, <P>) or they can be spelled out as part of a stylesheet. (For further treatment of stylesheets see Part 7.)

To change the color of the text in an entire paragraph to purple, write:

Markup Output
<P STYLE="COLOR: #CC0099">
This is some purple prose.
</P>
This is some purple prose.


To change the color of a single word or phrase, you can add a STYLE attribute to a <SPAN> tag. In the example below, only the word "purple" is treated:

Markup Output
This is some
<SPAN STYLE="COLOR: #CC0099">purple</SPAN>
prose.

This is some purple prose.




3.2 | THE MYSTERIES OF COLOR CODE


3.2.1 · Colors By Hexadecimal Code

The most precise and reliable way to specify colors for Web pages involves hexadecimal specification; colors are invoked as a trio of numerical settings for red, green, and blue (RGB). These numbers are written in the base 16 numbering system, which to the untrained eye looks like a strange hodgepodge of letters and numbers.

In other uses of an RGB system (for instance, in popular graphics programs), the values are usually given as regular, decimal numbers. I can specify a vivid RGB blue in Photoshop by plugging in 11 for red, 4 for green, and 232 for blue. But in HTML things are a bit different; actually, 8 bits different.

The HTML color scheme was devised for graphics systems that devote 24 bits of information to the color value of any given pixel. This was the high end for graphics cards in the early 1990s. RGB color implies three registers, each with 8 bits allotted to it (8+8+8=24). A bit is a binary element that may have one of two values, 1 or 0. Thus each of the three registers of the RGB color system can hold one of 28 or 256 values, making the total number of available colors 2563 or 16,777,216 (a number once identified in video card settings as Millions of Colors).

Having both 2 and 8 among its factors, 16 is a convenient number for binary systems and particularly for 8-bit arrays. Machine-code programmers regularly work in hexadecimal, so it seemed natural enough to Tim Berners-Lee and friends to handle HTML color in this way.

Okay, it's weird. But just imagine how impressed your friends will be when you notice how well their 33CC99 wallpaper matches the 006600 carpets!

3.2.2 · The Joy of Hex

A few words about base-16 numbers: they differ from decimal (base-10) numbers in that they advance by sixteens instead of by tens; this means that in counting from 1 -- which is the same in any number system -- to 10 -- which is ten in decimal but sixteen (decimal) in hexadecimal -- things get a little strange. To wit, you need six more numerals in base-16 to count from 1 to 10:

Base 10
12345678 91011121314 1516
Base 16
12345678 9ABCDE F10

As we've observed, Web colors are based on 8-bit registers, meaning the maximum value for each of the three color elements (R-G-B) is 28 or 256. But computer programmers always begin counting from zero (or as we like to say mnemonically: All good programmers start with nothing). Thus the range of register values actually runs from 0 to 255. 255 in hexadecimal is FF (15 sixteens plus 15 ones). Theoretically a Web color can be specificed by any triplet of values from 00-00-00, where R, G, and B are all kept flat, producing black, to FF-FF-FF, where all three settings are at full blast, producing white.

However, that's just the theory...

3.2.3 · 6x6x6, the Palette of the Beast

exploding cube of SAFE colors


Hexadecimal
003366 99 CCFF
Decimal
0051 102153 204255

3.3 | BACKGROUND GRAPHICS

3.3.1· The BACKGROUND Attribute

3.3.2· A Good Idea at the Time? 3.3.3· Advanced Use of Background Images
3.4 | IN-LINE GRAPHICS


3.4.1· The <IMG /> Tag
3.4.2 · The ALIGN Attribute 3.4.3 · VSPACE, HSPACE, and an alternative 3.4.4 · The BORDER Attribute

3.4.5 · The NAME Attribute

3.4.6 · Formats for In-Line Graphics

3.4.7 · GIF89a Transparency

3.4.8 · Vector Formats

3.4.9 · Color Modes


3.5 | ANIMATED GRAPHICS


3.6 | USING GRAPHICS WISELY


3.6.1· Controlling Bitload

3.6.2· Single-Pixel Effects


3.6.3· Thumbnails
3.7 | IMAGES AS LINK CUES



END OF PART 3

Index · Part 1 · Part 2 · Part 4 · Part 5 · Part 6 · Part 7 · Part 8 · Part 9 · Top



Course and Materials ©1997 - 2008 by Stuart Moulthrop and Nancy Kaplan