Creating Transparent GIFs

When you make a transparent GIF, you designate one color in the image's palette to be the transparent color. Pixels painted with the transparent color enable the background color to show through.

This technique is useful in getting rid of the bounding box that typically surrounds a graphic. When you compose an image in a graphics program, the workspace is almost always rectangular. Your image goes inside this rectangular region (the bounding box), and invariably some amount of space exists between the image and the edges of the box.

By choosing the color of the excess space pixels to be transparent, you make them disappear on the browser screen. This is what happened in Figure 5.1 shown previously. The bounding box pixels ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.