Spacer GIF
A spacer GIF is a small, transparent GIF image that is used in web design and HTML coding. They were used to control the layout of HTML elements on a web page, at a time when the HTML standard alone did not allow this. They became mostly obsolete after the adoption of Cascading Style Sheets.
History
David Siegel's 1996 book Creating Killer Web Sites [1] was the first known to publish the Spacer GIF technique. According to Siegel, he invented the trick in his living room.[1][2]
The Cascading Style Sheets (CSS) standard diminished the use of spacer GIFs for laying out web pages. CSS can achieve the same effects in a number of ways, such as by changing the margin or padding on a given element or by explicitly setting a relative position. If used properly, CSS reduces unnecessary code in a web page. Blank 1×1 GIFs are still occasionally used to fix a PNG rendering limitation in Microsoft Internet Explorer versions 5.5 – 6[citation needed].
Usage
It was recognised early on that although the size of table cells could not be set directly, each cell could contain an image through an <IMG>
tag. The size of image tags could be set independently, with their WIDTH
and HEIGHT
attributes. The table cell would then resize itself automatically to just contain this image, thus resizing itself. It was also realized that the displayed size was controlled entirely by the attributes and was independent of the actual size of the image file used (although a real image file[note 1] was still needed). Accordingly the same image file could be used for all the many spacer images needed on a web page. The only requirement was that this image was invisible, either by being the same color as the page, or by being transparent.
Spacer GIFs themselves were small transparent image files. GIF files were used as it was a common format that supported transparency, unlike JPEG. These files were commonly named spacer.gif
, transparent.gif
or 1x1.gif
. Prior to the widespread adoption of Cascading Style Sheets (CSS), the spacer GIFs were used to control blank space within a web page, that can be resized according to the HTML attributes it is given. The reason a spacer GIF is invisible is so that an HTML developer can create a table cell and fill the background with a specific color that can be viewed through the transparent spacer GIF. For instance, a developer seeking to create a square blue box 500 pixels on a side could use a separate blue 500×500 graphic at the expense of additional bandwidth. Instead, the developer can specify the table cell background color and specify the dimensions of a pre-existing transparent spacer GIF.
The technique was used around the same time as table-based layout. The web page was considered as a grid-based layout and it was desired to set the size of each grid section independently, as pixel-based sizes. The grid could be coded simply in HTML by use of the <TABLE>
tag, but this did not allow the size of table cells to be set individually.
Drawbacks
- Designs produced often looked perfect on the designer's display, but could look entirely different on the reader's display. Many designs became simply unreadable, especially as small-screen and mobile devices became popular.
- Implementing a design with spacer GIFs could be extremely tedious - particularly when making small changes to an existing design.
Attribution for the invention of the spacer GIF technique has been variously apportioned and claimed, but is generally placed with David Siegel in 1996.[1][2][3]
Obsolescence
The technique was obsoleted by a number of factors:
- CSS allowed sizes of HTML objects to be set directly. Although CSS' adoption was slow, owing to poor browser implementations and developer inertia, the simple ability to set sizes like this was available and usable from the early days in 1997.
- Table- and grid-based layouts were replaced by fluid layouts. These abandoned the attempt to control two-dimensional layout between elements. Instead the elements would be offered to the reader's browser and the browser would place them as best it could, according to the size of the reader's browsing window.
- Fluid design layouts made the setting of page element sizes on the user's browser less important. This was particularly evident where it removed the need to set sizes in absolute units such as pixels. As the web designer had never been able to control the size of the reader's screen window, the attempt to set sizes rigidly had always been a mistake.
References
- ^ sic – actually an image document - a file wasn't needed, but was invariably used.
- ^ a b Rønn-Jensen, Jesper (2006-03-03). "Justaddwater: Who invented the Spacer GIF". Justaddwater. Retrieved 2006-11-26.
- ^ a b Siegel, David (1997-10-02). "The Web is Ruined and I Ruined it". XML.com. O'Reilly Media. Retrieved 2015-07-08.
- ^ CKWS - Single-Pixel Gif Trick