- Before CSS, the HTML body tag had its own background attribute for a page-wide tiled image.
- CSS gave styling its own layer, separating background-color and background-image from markup.
- CSS3 added support for multiple background layers and true gradients, cutting the need for many image files.
- Newer formats, WebP and AVIF, compress backgrounds smaller than JPEG and PNG at a similar visual quality.
Before CSS: the body background attribute
In early HTML, a page background was set directly in markup, on the <body> tag itself.
<body background="tile.gif" bgcolor="#ffffff">The background attribute pointed to an image that the browser tiled across the whole page by default, with no separate styling language involved. bgcolor set a plain fallback color the same way. There was no equivalent of background-size, background-position or background-repeat: the image simply repeated, full stop, and the page's content sat on top of it.
This attribute was marked deprecated in HTML 4.01, in favor of styling the same effect through CSS, and it does not exist in the HTML5 specification at all. Browsers still render it today for compatibility with old pages, but it has had no place in current markup for a long time.
It is worth noticing what this early approach assumed: one background image, applied to the whole document, with the browser making every decision about how it repeated and where it sat. Any variation, a different background on one section of a page, required a different element with its own background attribute, since there was no concept of layering or targeting an arbitrary part of the page from a single rule.
Why GIF tiles were the standard choice
Early web connections were slow, and every byte of a page mattered. A small tiled image repeated across the whole background cost far less to download than one large image covering the same area, since the browser only had to fetch one small file and repeat it in the rendering engine.
GIF was the practical format for this. It compresses losslessly and stores color through an indexed palette limited to 256 colors, which is plenty for flat graphic patterns, simple textures and solid color fields, and produces small files for that kind of content. JPEG existed for photographic images with continuous color and smooth gradients, where its lossy compression gave much smaller files than GIF could for the same subject, but a photograph was rarely practical as a tiled page background given the connection speeds of the time.
A tiled background also had to tolerate its own seams by design, since there was no tool to test or fix a repeat before shipping it. Many early tiles were simple enough, a single flat color, a thin line, a small dot pattern, that the seam problem barely came up. More ambitious, detailed tiles were harder to pull off well without the kind of workflow described in seamless tileable textures, which did not exist as a defined practice yet.

CSS takes over: background-color and background-image
CSS introduced its own background properties, moving the same visual effect out of HTML markup and into a separate styling layer. background-color and background-image let a page set its background through a stylesheet rather than an attribute on the body tag, which meant the same visual treatment could apply to any element, not only the page as a whole, and could be reused across many pages from one shared file.
This separation is the same principle behind the rest of CSS: markup describes structure and content, while a stylesheet describes appearance. A background set in CSS could be changed site-wide by editing one file, instead of editing the background attribute on every page's body tag.
Putting background rules in a stylesheet also meant the browser could cache that one file across every page on a site, instead of re-parsing a repeated attribute value in every document's markup. A visitor who moved from the homepage to an inner page did not need to fetch the background rule again, since the stylesheet had already been downloaded and cached.
More control: position, attachment and repeat
CSS backgrounds grew a set of properties the old HTML attribute never had.
background-positionplaced the image anywhere within its element, not only tiled from the top-left corner.background-repeatoffered values likerepeat-x,repeat-yandno-repeat, where the old attribute only ever tiled in both directions.background-attachmentaddedfixed, which keeps a background still relative to the viewport while the page content scrolls over it, a visual effect the body attribute could not produce at all.
Each of these let a designer place one image precisely, rather than accepting a full tile across the whole element by default.

CSS3: multiple backgrounds and background-size
Later CSS specifications grouped background and border properties into a dedicated module and expanded what a single element could do. The biggest change was support for multiple background images on one element, written as a comma-separated list in background-image, with each layer able to have its own position, size and repeat behavior.
.panel {
background-image: url("grain.png"), url("texture.jpg");
background-size: 300px 300px, cover;
}background-size arrived alongside this, letting an image scale to cover or contain its element, or to an explicit size, instead of always rendering at its native pixel dimensions. Together, these let one element combine a texture such as a kraft paper texture, a tint and a pattern without any extra markup or server-side image compositing, and the loading behavior of each of those layers is still worth checking against the guidance in the CSS background image guide.
Gradients move from images to CSS syntax
Before CSS gradients existed, a smooth color transition behind content had to be a saved image file: a designer rendered the gradient in an image editor, exported it as a JPEG or PNG, and set it as a background-image like any other photo. Every change to the colors or direction meant re-exporting a new file.
CSS gradient functions, linear-gradient() and radial-gradient(), moved that work into the stylesheet itself. A gradient became a value written directly in CSS, computed by the browser at render time, with no image request at all. This also made gradients responsive and easy to adjust: changing a color stop is a one-line edit, not a re-export.
A CSS gradient also resizes perfectly with its element, since the browser recalculates it at whatever dimensions the box ends up being. A saved gradient image, by comparison, either had to be stretched, which could reintroduce banding or distortion, or exported at a fixed size that only fit one layout.
Newer image formats: PNG, WebP, AVIF
Image formats kept evolving alongside CSS. PNG became the standard lossless alternative to GIF for images that needed more than 256 colors or a full alpha transparency channel, something GIF's binary transparency, fully opaque or fully transparent per pixel, could not provide.
More recently, WebP and AVIF arrived as newer formats aimed squarely at the web. Both support lossy and lossless compression in one format, and both typically produce smaller files than JPEG or PNG at a comparable visual quality, which matters directly for background images, since a background is often one of the largest files on a page. Browser support for both has broadened over time, which is why a background in CSS is often served through image-set() or a <picture> element, letting the browser choose the smallest format it understands rather than committing to one file for every visitor.
Each new format solved a specific limitation of the one before it. GIF's 256-color palette was fine for flat graphics but poor for photographs. JPEG handled photographs but offered no transparency and always lost some detail to compression. PNG added lossless quality and a full alpha channel but produced larger files for photographic content. WebP and AVIF arrived to close that remaining gap, aiming for photographic quality at a smaller file size than either JPEG or PNG typically achieved alone.
Where backgrounds stand today
A background today can be a single photographed texture, a CSS gradient with no file at all, an SVG pattern, or several of these layered together on one element, with a size, position and repeat value chosen independently for each layer. None of that was possible with the original body attribute, which offered exactly one image, tiled, with no other options.
Flat graphic patterns, the kind GIF tiles handled well in the early web, are still around in styles like a memphis pattern, now usually delivered as a larger photographed or rendered sheet rather than a small repeating tile, since bandwidth is no longer the limiting factor it once was. Choosing the right file dimensions for a given screen or print output is its own subject, covered in background resolution for web and print.
The underlying goals have not changed much: cover a surface, set a tone, support the content on top of it, and do it without costing too much to load. What changed is the toolkit available to do that job, from one HTML attribute to a full set of CSS properties, gradient functions and modern image formats working together.
Responsive design added one more requirement that the original body attribute never had to answer: the same page now often needs a different background treatment on a phone, a tablet and a desktop screen, through media queries in CSS or srcset and sizes on an img-based background. A single tiled image, applied the same way regardless of screen size, was a reasonable default when there was effectively one kind of screen to design for.



