Stuart Moulthrop & Nancy Kaplan University of Baltimore School of Communications Design · 2000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Week 3: Color and Graphics |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
3.1 | ADDING COLOR TO WEB PAGES You can specify colors for several HTML objects including the background for an entire page and the main body text. You can also assign colors to several aspects of the link cue: when it marks a link to a page not yet visited; when it marks a link to a previously visited page; and when it is currently active (i.e., while the mouse button is down over the cue). There are several methods for specifying colors. Some of these belong to the earlier versions of HTML (3.2 and its precursors), while the more modern techniques involve Cascading Stylesheets, a component of HTML 4.0 ("Dynamic HTML"). At this writing, major browsers support all methods of color setting, though at least one (the <FONT> container) has been deprecated by the W3C, marked for exclusion from future standards. We'll cover stylesheet color management in Week 5. At this point we'll go over the older methods, most of which remain in very widespread use until browser support for stylesheets becomes universal. 3.1.1 · In the <BODY> TagWith Navigator 1.1 (early 1995) Netscape introduced solid-color backgrounds for Web pages. This technique was later incorporated into the HTML 3.2 specification. Background colors are set by adding a BGCOLOR attribute to the initial BODY tag (the first tag of the <BODY></BODY> container); for example, the BODY tag of this page contains the attribute BGCOLOR="#FFFFFF" which sets the page background to white. (More about that mysterious series of "F"s a little later on.) In Netscape Navigator and Internet Explorer, page colors can be set by name (e.g., bgcolor="white"), though these names may not be recognized by all browsers. Here's a list of supported color names. Though convenient, names are not the best way to set page colors; a better method is hexadecimal coding, discussed below. A number of other attributes can also be added to BODY in order to set page colors:
3.1.3 ·
Applied to a short span of text
3.2 | THE MYSTERIES OF COLOR CODING 3.2.1 · Colors By Hexadecimal Code
3.2.2 · The Joy of Hex
If you're not choosy, you can use many interesting values
to invoke Web colors: A11EEE, 666999, BA0BAB.
When the browser encountered a color its graphics card could not display, it would either shift the color to the nearest supported value, or it would dither the color by creating a pattern of alternating pixels in a kind of techno-pointillisme derisively called "Web pox." This could get very, very ugly. To deal with this problem, Web designers learned to use a reduced subset of the full 24-bit palette. This was the set of Web-safe colors. Such colors were guaranteed to display without shifts or dithering on any computer with at least 8-bit color support. Behold, the Palette of the Beast:
Here's another view of the 216 kosher colors, this time in an exploded-cube arrangment:
In theory 8-bit color produces 256 possiblities; but the Web-safe palette actually contains only 216 options. This is because Netscape and Microsoft, makers of the two most popular browser programs, reserve 40 colors for use only in interface elements such as window borders and icons. Here's a complete catalog of Web-safe colors, with links to sample pages showing how they look against contrasting selections for text color. In terms of hexadecimal coding, the 216 "Web-safe" colors all have this in common: their R-G-B elements are each set with one of the following six values:
So of the following, only the codes in red represent Web-safe colors. The others are impostors:
But now we come to a rather difficult question: Should we still bother with Web-safe colors in this ultra-sophisticated 21st Century? 3.2.4 · When "Safe" Colors Are Needed
Like most things having to do with the Web, the great color debate is largely a matter for personal judgement. On the one hand: From a PC-centric point of view, Web-safe colors have outlived their usefulness. Desktop systems have dropped in price well below $1,000 and in almost all cases those systems incorporate graphics cards that support 24-bit color at some reasonable resolution. On the other hand: Web publishers are turning increasingly toward platforms other than the traditional PC -- television set-top boxes, handheld digital assistants, even enhanced cellular phones. It may be some time before these devices can all handle 24-bit color. What are some reasonable, general rules for Web color? The infamous "Netscape enhancements" also gave authors the ability to build background patterns by filling the screen with multiple adjacent copies (or tiles) of a given image. This is very much like the digital "wallpaper" you can set up in Windows and MacOS. Here is a (rather garish) sample page. 3.3.1· The BACKGROUND Attribute To establish a tiled background, insert a BACKGROUND attribute into the initial BODY tag; the value of the attribute will be the electronic address (URL) of the desired image file. This may be either a fully-qualified URL or (more commonly and sensibly) a relative reference to a graphic within your own system. The graphic in question may be either in JPEG or GIF format (for more about these formats, see below). More recent browsers even support animated GIFs for tiled backgrounds. The University of Baltimore's Communications Design program maintains a sampler site with a large number of background images available for copying or downloading. Use at your own risk. You may use both a BACKGROUND and a BGCOLOR attribute in your BODY tag. Graphical backgrounds were meant to impart a "textured" look to Web pages... which they do... but it's notoriously difficult to read words against all but the most carefully designed textures. Intrusive or awkwardly tiled background graphics are a sure giveaway of amateur Web design. Lately the pros have been opting for conservative, solid-color backgrounds -- and while no one is eager to resurrect the "gunmetal gray" that was standard at the dawn of Web time, a large number of pages wear black or white these days.
Nonetheless, some people still use background graphics in their pages. Instead of crude wallpaper tiling, these designers use more advanced techniques. Here are two of the more common:
As you can see in this example, some designers use a single large graphic to lay in a system of rules and borderlines to give visual structure to pages with standard formats. Particular page content is then laid on within a table structure (see Week 4) so that it aligns properly with elements of the background. The background image in this case is not meant to tile, so it is given dimensions large enough to fill the screen on one iteration: 1200 pixels in width and 1000 pixels in height. This technique does use tiling, but only in the vertical dimension. The designer creates a graphic that is not very high (1-5 pixels) but is very wide (1200 pixels or more). When laid in as a tiling background, this image creates a column of distinct width and indefinite height (since the image will tile as many times as needed to match the extent of the page). Here's an example:
Content such as navigation buttons can be laid over this column. The color can be varied to indicate departments. Patterns or designs can be substituted for the simple solid block. Background graphics are close cousins to a more common form of Web image -- in-line graphics: these are images that appear only once at a given location, integrated into the flow of words and other page elements. 3.4.1· The <IMG> Tag
In-line graphics are controlled by a single tag: <IMG> or the "image tag." IMG is another of the rare solitary features in HTML: it occurs not as a container but always solo (there is no </IMG>).
The tag that introduces the image contains several critical parts. (If you look at the source for this page, you'll see that this image tag has some other bits as well, but we'll defer them for the moment.) The four attributes discussed below -- SRC, WIDTH, HEIGHT, and ALT -- can be considered indispensable: all image tags must have them. We'll go on to discuss some other attributes which are technically optional, though they may be required in certain circumstances.
3.4.2 · The ALIGN Attribute The ALIGN attribute in the IMG tag sets the relationship of the image to the text stream in which it is located. In the earliest version of HTML there were three ways to align in-line graphics:
These attributes allow you to create a gutter, specified in pixels, between the image and what lies on either side of it, whether that be text or the page margin. These attributes are obviously useful in coordinating images with words. If you look at the example in the previous section, which has HSPACE set to 20 pixels, you'll see that the same amount of space is left on both left and right. In the case of VSPACE, equal gutters are created at top and bottom. If you care about crisp alignment of elements (and in most cases, designers do), then this can be a serious problem. Some designers prefer not to use HSPACE and VSPACE to control gutters: they simply insert along one edge of their images a strip of blank color that matches the page background color. This feature serves as the gutter. This solution has some drawbacks: you can't change the orientation of the image with respect to the text without editing the native graphics file; you can't re-use the same image on your page in two different orientations; and if you've created your images with white gutter strips assuming a white page background, you'll have to rebuild them should you change background color (unless you used GIF89a transparency; see below).
You'll notice the thick black borders around the image at right. These were set by adding a BORDER attribute to the IMG tag. This attribute specifies a border size given in pixels. If no BORDER attribute is set, then no border will appear if the image is treated simply as an in-line graphic. However, if the image is used as a link cue (see Section 3.7 below) then a visible border will appear even if none has been specified. If you want to suppress the border on a graphic link cue, you must include the attribute BORDER="0". The color of the border is variable. If your image is not a link cue, then the border color is the same as the body text color set for your page (black by default). In the case of a graphical cue, the color will be the one assigned either to unvisited links (blue by default) or visited links (purple by default). The border will turn to the active link color when the user holds the mouse button down over the graphic.
The attribute NAME may be used in IMG tags. It is required if you want to use JavaScript to change the source assignment of the image, a technique required for roll-over effects (see Week 7). This attribute is not required if you are using images simply for display purposes or as link cues. For the moment you should register two facts about NAME: 3.4.6 · Formats for In-Line Graphics
If you've worked mainly in print up to now, the shift to Web graphics may be a bit disconcerting. To begin with, most of the image formats with which you're probably familiar -- TIFF, EPS, BMP -- aren't supported in the HTML specification. This is particularly true of vector formats (discussed below). Also, all Web graphics display at 72 pixels (or "dots") per inch (72 dpi). If you have a massive, 300 dpi pre-print TIFF, you could indeed convert it to a massive, 300 dpi JPEG and try to feed it through the Internet. And it might look subtly better than the equivalent 72 dpi graphic... when all its bits finally arrive... nine years hence. Mostly you will need to forget what you know about print graphics. The Web is different. Without special plug-ins, most major Web browsers can only handle one type of digital image -- a bitmap or raster graphic which is essentially a table of numbers holding a value for each tiny color dot that makes up the image. Browsers generally support two bitmap formats: The practical difference between GIF and JPEG images should be apparent in the following example, unless your system has very limited display capabilities:
Being bitmaps, both images contain the same number of pixels; but the JPEG graphic (left) has a larger color palette than the GIF graphic (right). That's why the GIF seems so fuzzy: many of its pixels are not quite the right color: a direct result indexed color (in this case, the Web-safe palette). GIFs are perfectly fine for simpler graphics or line art, though; and in the case of small, simple graphics, GIF files are often smaller than JPEGs. The GIF file here is 38.7 kilobytes; the JPEG comes in at 58.4 -- about a 30% variation.
Photoshop has had the ability to save GIF files with transparency since version 4.0. Other major graphics programs do the same. At this writing, there's no built-in browser support for transparency in JPEG images. Bitmaps are not the only way to encode digital images. Since those bright folks in Silicon Valley invented Postscript, it's been possible to control digital images in a much more powerful and flexible way -- not as mosaics of tiny dots, but as curves whose angles and dimensions are specified by elegant mathematical equations. Images defined in this way are called vector graphics. Vector graphics have enormous advantages over bitmaps: they can usually be expressed with far fewer symbols (a few kilobytes as compared to a few hundred for a bitmap) and they can be flexibly scaled without loss of fidelity. But like our old friend the carburetor, bitmapped images just keep hanging on. They're crude, but there's basically one way to handle them and no one has much proprietary stake in the method anymore. Meanwhile several companies offer competing vector-graphics standards and none has yet emerged as the clear winner. The most popular formats for vector graphics today include Encapsulated Postscript (EPS), Portable Document Format (PDF), and for vector-enabled media files, Macromedia Flash. All of these formats require a plug-in in order to be interpreted by major browsers. Only Flash has made really significant inroads (so much so that the Flash plug-in ships with both Netscape and Microsoft browsers these days). We're still a few years away from being able to use vector graphics as the standard for Web publishing, but the day should come eventually.
Since the very early days (Netscape 1.1), Web browsers have been capable of displaying multiple image sequences combined into a single animated GIF file. This capacity for combination and playback is another part of the GIF89a standard, which was only a decade or so ahead of its time. Animated GIFs require no special HTML mechanism -- they are marked up as if they were ordinary, static GIF files and they have the same file extension (.gif) as their more sedentary cousins. Animated GIFs can be created easily enough within most major graphics programs (in Photoshop, for instance, by converting a series of layers into animation frames). A number of free or shareware programs can help you assemble animated GIFs from component images; for the Mac, we still like Yves Piguet's elegant GIFBuilder. Macromedia's Flash also exports animations in GIF89a format and it has become a major tool for creating this kind of content. However, once you build an animation in Flash you can also save it in native Flash format as a vector-based movie. It can be hard to decide between Flash format and animated GIF. GIF is a bitmap format, hence it requires fairly large file sizes in comparison to native Flash. But Flash requires a plug-in and animated GIF does not. Often it's the more sophisticated features of Flash -- clickable interactivity and scripting capabilities -- that decide the issue. To see how an animated graphic can be created out of simple components, see this anatomy of an animated GIF. 3.6.1· Controlling Bitload
Perhaps the most common complaint about Web pages involves agonizingly slow load times -- the infamous World Wide Wait. Even today (!) these slowdowns are often caused by inappropriate use of graphics. Here are some rules of thumb to help you avoid overload: These allowances are very liberal by some standards. We know of many large-scale Web publishers who insist on much stricter numbers.
3.6.3· Thumbnails Suppose you have an image that just can't be reduced. Here's a sensible compromise -- put a thumbnail version of the image on your page, like this:
Create a link from the thumbnail to a separate page containing the full-size graphic. Add a caption or other information indicating the dimensions of the larger image and (possibly) how big the file will be. In terms of the size limitations we proposed above, only the thumbnail graphic counts. Since you've warned users about the large size of the full-format graphic, you could plausibly argue (though your boss or client might not agree) that it is exempt from the 150k rule. 3.6.4· Image Slicing and Code Generators
You can try to produce this technique by hand. With careful work and lots of trial-and-error, you can create a sliced table layout that looks indistinguishable from the original image... in Microsoft Internet Explorer. Viewed in just about any version of Netscape Navigator, however, a simple table layout with one cell for each slice of the image leaves maddening one-pixel gaps. At this point many people turn to code-generating programs like Macromedia's Fireworks and Dreamweaver. These programs outfox Netscape's quirky layout engine by creating a table with a large number of extra cells. These cells are occupied by single-pixel "shim" graphics which force the image slices into the correct position. The result looks just fine, as you can see in this example. But have a look at the markup for that example page and you'll see line after line of arcane, unreadable code which (trust us) won't make much sense to you even after you've figured out tables. Also, the automated slicing operation produces a plethora of files, including the shim graphic and a dummy HTML page, all of which you need to put into the right directories and carefully integrate with the rest of the page you may be building. Sorting out the pieces is not a simple task. Fireworks and other automated image-slicers are sophisticated power tools. You should not rely on them -- in fact, we suggest you don't even use them -- until you've built a number of table-based pages by hand. Even then, you'll need to pay close attention to what your code generators are doing. These are tools aren't really meant for casual users.
If you use a Macintosh to produce Web graphics, there's something you urgently need to know: unless you've adjusted the gamma curve on your display, then on most computers in the world, your work looks dark and muddy! The gamma curve expresses the relationships among brightness and contrast for the red, green, and blue elements of your display. Because they are designed to work even with the cheapest video cards and monitors, Windows systems use a particularly crude gamma curve called television gamma -- the same that's used in old-fashioned, non-HD, analog TV. Meanwhile, at least since they crossed into millions-of-color territory back in the late eighties, Macs have used a more refined gamma curve with considerably more gradation in mid-range tones. (Mac displays either come from Apple or are built to their specifications, so Apple can insist on higher standards.) Result: Mac screens almost always seem both brighter and softer than their anything seen through Mr. Gates' Windows. So you have a better display than 95% of the world. Good for you -- unless you happen to be a graphic designer. Then the color choices you make on your bright, elegantly calibrated Mac screen may be totally imperceptible to anyone stuck with the Other Stuff. In some cases design elements can't be seen with the naked eye. Crucial lettering (a client's slogan, for instance) may disappear from view. You don't need to give up your Mac. Simply go to the Monitors and Sound Control Panel and select the Colors option. Click the Calibrate button. This will bring up a series of dialogs (in Windows parlance, a "Wizard") that will help you create an alternative gamma setting for your Mac display. During this process you will be given the chance to change the current gamma setting. Select Televison gamma. The profile you establish in this procedure takes immediate effect on your computer, but you can switch back to your previous setting any time you like. We strongly recommend that you set up a Windows-equivalent monitor profile for your Mac: we've seen many fine designs fail miserably because their creators didn't take account of the Dark Side. As we've just seen in the thumbnail example above, images on Web pages are rarely just decorative or illustrative. Like words, they too can be cues for departing and arrving links: The markup for the above example looks like this:
<A HREF="key_myst.htm"><IMG SRC="images/key.gif"></A>
Note that the IMG tag is contained within the anchor container, taking the place of the words in a vebal link. As we explained with respect to the BORDER attribute above, making a graphic into an active cue can cause a border to appear even if you have not specified a border width. In some cases you may want the border to be visible, either to signal that this graphic is indeed a cue, or to register information about whether the arrival page has been visited. If you don't want to invoke these features, set an attribute of BORDER="0" in the IMG tag. Imagemapping is a special case in which a graphic becomes a cue for multiple links. Various regions of the graphic (often called "hot spots") are mapped to various arrival points. For example:
This aerial view of midtown Baltimore supports links to six other pages (see the numbers); clicking on a numbered square activates a link.
In ancient times (pre-1996), imagemapping required a special program
called a Common Gateway Interface Script (CGI)
running on the same machine as the Web server.
With Navigator 2.0, Netscape introduced client-side
imagemapping, where all the instructions for handling
hot spots are contained in the browser code and all the
specifications for hot spots are given in the page markup.
This feature is now universally supported.
<MAP NAME="aerial_map">
Note that AREA is always an empty container: the crucial information occurs in the attributes of the initial AREA tag. The SHAPE attribute in the AREA tag can also be set to CIRCLE, POINT, OVAL, or POLYGON (with corresponding changes in the coordinates specified). The POINT option in effect describes a circle within which a mouseclick activates the link. (If you omit the SHAPE attribute, the browser will assume "rect" by default.) The connection between the MAP container and the IMG tag is made through an attribute called USEMAP; here is the IMG tag for the Baltimore imagemap shown above:
<IMG SRC="images/aerial.gif"
USEMAP="#aerial_map">
Note the "#" in the USEMAP attribute, as in the construction you learned in Week 2 for the departure half of a doubly-anchored link. The same rules apply here about case sensitivity: the value of USEMAP must be letter-for-letter identical to the NAME attribute in the MAP container. Though no ANCHOR container is present, you still need to include a BORDER="0" attribute if you wish to suppress the borderline around an imagemapped image. (In the example above we do not suppress the border.) You can do all the same things with AREA that you can do with the anchor tag. The value assigned to the HREF attribute may be a MAILTO: or JAVASCRIPT: string, enabling e-mail and scripting links from imagemaps. Likewise you may add a TARGET attribute to an AREA tag, allowing control of windows and frames. Like IMG tags, AREA tags must also contain an ALT or LONGDESC string; though in this case the alternative text should describe not the image as a whole but the hot spot or the link that it cues.
END OF NOTES FOR WEEK 3
Course and Materials ©1997 - 2000 by Stuart Moulthrop
and Nancy Kaplan | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||