5.1. Image Formats

Although static images can seem unexciting in today's world of Web-delivered content, the Web would be a very boring place without their use. As you will see in the following sections, there are plenty of options and formats to consider when using images in your Web documents.

5.1.1. Web Formats

The Web supports three main formats of graphics—GIF, JPEG, and PNG. The following sections detail the capabilities and suggested uses for each type of graphic.

5.1.1.1. GIF

The Graphics Interchange Format (GIF) was created in the late 1980s. It was originally used by the CompuServe online service to deliver graphic content to their subscribers. The GIF format uses LWZ compression to help keep the file size small. Version 89a of the GIF format added the ability to encapsulate several images within one file, giving the format animation functionality.

The GIF format has the following characteristics:

  • Supports up to 8-bit color (256 colors)

  • Supports transparency

  • Is stored in a compressed, lossless format

  • Can be interlaced and used for rudimentary animations

As you can see, GIF is a versatile format. The main drawback to the GIF format is the limit of 256 colors, which can limit what the format can display.

Patent problems plagued the GIF format's adoption in the late 1990s. Unisys, the patent holder of LWZ compression, chose to terminate their royalty-free licenses and charge royalties for use of the format. This practice spurred the development of alternative formats for ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.