spacer.md1 min read

← index

A one-pixel image was a layout engine

A short note on building pages out of transparent GIFs.

1 min

The interesting thing about the spacer GIF is not that it was a hack. It is that it was a good hack, in the sense that it worked reliably across implementations that agreed on almost nothing else.

A transparent single-pixel image, stretched with width and height, gave you the one thing HTML would not: a box of an exact size that survived the trip through four browsers with four different opinions about whitespace. It was sound engineering against the platform that actually existed rather than the one in the specification.

What replaced it was not a better hack. It was the platform finally growing the feature — margins that collapse predictably, then flexbox, then grid. That is the pattern the whole history follows, and the spacer GIF is the cleanest example of it: the workaround is a bug report written in production traffic, and eventually somebody reads it.