Understand graphics formats
Find graphics
Insert an image on your page
Control image placement and appearance
Create image links
Use CSS with images
Web pages without pictures can be pretty dull places. The content might be great, but today’s world is visually oriented. People who visit your site expect to see more than straight text. But how do you give it to them without having to invest in (and learn how to use) a lot of expensive software? The good news is that there are more resources available than you’ll ever have time to check out, and many of them are free. But before you begin working with graphics, you must
There are scores of different ways to create, save, store, and send graphics over the Internet. Fortunately, you don’t need to be
Although the sheer number of different graphics formats out there is enough to give you a
If you are doing navigation
When an image is saved, it is compressed to save space and transfer faster. Each of these formats compresses images in a different way. GIF uses something called
LZW
(named after its inventors, Lempel-Ziv and Welch) compression. When an image is saved, LZW takes rows of pixels with the same color and
If you are planning to use photos on your Web page, GIF is not your best option. The reason, again, is compression. A photograph
PNG
(pronounced
ping
), stands for Portable Network Graphics. It was developed in response to the controversy over the licensing fee being charged for the GIF compression program and looks to be a very
| Note |
If you use a scanner, you can also capture your images as bitmaps (BMP). Although Internet Explorer will display bitmaps, there are two good reasons to avoid them on your Web pages. First, Netscape does not support them, so your images will not display on Netscape browsers. An even better reason to avoid them is that bitmap files are larger and will slow down your page loading time. Always convert bitmaps to GIF, JPEG, or PNG files. |
Whenever you are dealing with images and
The
color depth
or
bit depth
of an image refers to how much “computing power” is packed into the processing of an image. The greater the bit depth, the more colors the image can contain, and the larger the
| Tip |
If you are creating or editing your own graphics, you can choose even smaller color depths. This is a great way to make image files load faster, as long as you don’t need as high an image quality. |
When it is said that an image supports transparency , it means that it is possible to cause one or more of the colors in the image to act as if it were transparent, thus matching the background color of the Web page. This makes your graphics look much cleaner as you use them on different pages, allowing you to create a “cut out” effect and making the borders of the picture invisible. GIF and PNG support transparency; JPEG does not. If you are creating a logo for your page, you probably will want to use GIF or PNG.
Image compression is said to be lossless when the graphic can be compressed or saved without any loss of information. In other words, the image is exactly the same before and after the compression process. On the other hand, lossy compression involves a loss of data when the image is saved. GIF and PNG are lossless compression formats. JPEG is lossy, but the loss of quality generally is small.
Have you ever loaded a Web page and noticed that the images start out fuzzy or looking like they were made with blocks, then after a few seconds they sharpen into focus? These images are
interlaced
. Interlacing is a means of saving an image so that when it loads, it gradually progresses from a low resolution to a high resolution. This gives the
Some formats support images in grayscale , that is, a large range of shades from white to black. If you want to put a black-and-white photograph on your site, or display a color picture as black and white, you will want to use a format that supports grayscale. JPEG and PNG support grayscale; GIF does not.
Table 6-1
|
GIF |
JPEG |
PNG |
|
|
Color Depth |
256 |
16.7 million |
16.7 million |
|
Compression |
Lossless |
Lossy |
Lossless |
|
Transparency |
Yes |
No |
Yes |
|
Interlacing |
Yes |
No |
Yes |
|
Grayscale |
No |
Yes |
Yes |