CSS Background Texture: Seamless Tiles, Color and Dark Mode
How to add a seamless background texture in CSS: tile size, background-repeat, tinting with background-blend-mode, dark mode, and file weight.
On this page
To add a background texture in CSS, put a small seamless tile behind the element with background-image, let the default background-repeat: repeat fill the area, and set the grain scale with background-size. To color it, use a grey tile on top of a background-color with background-blend-mode: hard-light, so one file works for almost every color, including dark mode (at pure white or pure black only half the grain shows).
This guide covers the parts most tutorials skip: what tile size stays sharp on a phone, why multiply turns your brand color muddy, how to swap light and dark with one line, and how much a texture weighs. The examples use the real tiles from our free textures, measured on November 30, 2026.
Key takeaways
- A seamless tile has matching opposite edges. `background-repeat: repeat` is the default, so one tile fills any box.
- Show the tile at half its pixel size (a 512 px WebP at `background-size: 256px`) and it stays sharp on 2x screens. A smaller size gives a finer grain.
- Tint a 50% grey tile with `background-blend-mode: hard-light`. Your color stays exact; `multiply` darkens it.
- Dark mode is a color swap, not a second file: put the color in a CSS variable or use `light-dark()`.
- Our 11 WebP tiles weigh 6 KB to 52 KB (median 16 KB). The 1024 px JPG versions weigh 138 KB to 302 KB.
Disclosure: Free Textures is made by the All SVG Icons team. The CSS in this guide works with any seamless tile.
How a seamless texture works
A seamless texture is an image whose left edge continues into its right edge and whose top edge continues into its bottom edge. Place copies side by side and you see one surface with no line where they meet. That is what lets a 512 px file cover a 2560 px screen.
The browser does the repeating for you. background-repeat defaults to repeat, which tiles in both directions and clips the last copy at the edge of the box. The other values matter less for textures, but it helps to know what they do (MDN, background-repeat, read November 30, 2026):
| Value | What it does | Use for a texture? |
|---|---|---|
repeat | Tiles both ways, clips the edge copies | Yes, the default you want |
repeat-x / repeat-y | Tiles along one axis only | Only for a band or a strip |
space | Fits whole copies only, adds gaps between them | No: the gaps break the surface |
round | Stretches copies so a whole number fits | Rarely: it can distort the tile |
no-repeat | Shows the image once | No |
The minimal version is three properties:
.surface {
background-color: #f4f1ea;
background-image: url("/textures/paper.webp");
background-size: 256px;
}Always set a background-color too. It shows while the tile loads and stays if the file fails, and it is the layer the tile blends with in the next sections.
The hard part is the tile, not the CSS. A tile with one bright corner or a single large stain repeats that mark in a grid, and the eye finds the grid fast. Before you use a texture on a large area, view it at 3 x 3 copies. If a mark jumps out, use a calmer tile there.
Tile size and sharpness
background-size sets how large one copy of the tile is drawn. With one length, such as 256px, the height follows the image's own ratio (MDN, background-size).
Two rules decide the value:
- Sharpness. On a 2x screen (most phones and many laptops), a tile drawn at 256 CSS px uses 512 device pixels. Give it a file with at least that many pixels, or the grain goes soft. Our WebP tiles are 512 x 512 px, so they stay sharp up to
256px. The JPG tiles are 1024 x 1024 px and stay sharp up to512px. - Grain scale. The same file drawn smaller looks finer. Our texture page offers 128 px (fine), 256 px (medium) and 512 px (large). Paper and plaster usually look right at 128 px to 256 px. Linen and concrete can go larger.
Do not use cover or contain for a texture. cover scales the tile to the whole box, so a 512 px file on a 1600 px hero gets blown up three times and blurs. A fixed length keeps the grain the same size on every screen.
For more than one file size, image-set() lets the browser pick by screen density. It has been Baseline widely available since March 2026 (webstatus.dev, checked November 30, 2026):
.surface {
background-color: #f4f1ea;
background-image: image-set(
url("/textures/paper.webp") 1x,
url("/textures/paper-1024.webp") 2x
);
background-size: 512px;
}Tint one grey tile with background-blend-mode
Most texture packs ship a separate file per color. That falls apart once you need a brand color, a hover state and a dark theme. The fix is to ship one grey tile and let CSS add the color.
background-blend-mode blends an element's background images with each other and with its background color (MDN, background-blend-mode). The image is the top layer and the color is the layer under it. Which mode you pick decides whether your color survives:
| Blend mode | 50% grey over your color gives | White | Black | Bright yellow #ffd600 |
|---|---|---|---|---|
multiply | Your color at half brightness | Mid grey #808080 | Black, grain gone | Mustard #806b00 |
overlay | Your color, but the grain fades near white and black | White, no grain | Black, no grain | #ffd600, weak grain |
hard-light | Your color, unchanged | White, darker grain shows | Black, lighter grain shows | #ffd600, grain on top |
The math is in the spec and summed up by MDN: hard-light acts as multiply where the top layer is darker than 50% grey and as screen where it is lighter (MDN, blend-mode). At exactly 50% grey, both halves leave the color under it as it was. So a tile that averages 50% grey keeps your color on average, and its light and dark grain moves around it in both directions. overlay also keeps the color, but it is driven by the color layer, so the grain vanishes on white, black and fully saturated channels. multiply can only darken, which is why most "paper texture CSS" tutorials end up with a dirty-looking page.
This only works if the tile really averages 50% grey. We measured ours: all 11 average between 127.8 and 128.2 on a 0 to 255 scale. A tile you make yourself needs the same step: convert it to greyscale, then shift its levels until the average sits at 128.
The full rule, with a real tile:
.surface {
background: #f4f1ea url("https://assets.allsvgicons.com/tex/paper.webp") 0 0 / 256px;
background-blend-mode: hard-light;
color: #000;
}That URL is fine while you prototype. For production, download the file and serve it from your own host, as our Free Asset License asks. background-blend-mode has been Baseline widely available since July 2022 (webstatus.dev), so current browsers need no fallback. Do not swap in mix-blend-mode: it blends the whole element, text included, with what is behind it.
Light and dark mode with one file
With a grey tile, dark mode is a color change. Keep the file, swap the color:
:root {
--surface: #f4f1ea;
--ink: #1a1a1a;
}
@media (prefers-color-scheme: dark) {
:root {
--surface: #14161c;
--ink: #f4f1ea;
}
}
.surface {
background: var(--surface) url("/textures/paper.webp") 0 0 / 256px;
background-blend-mode: hard-light;
color: var(--ink);
}If your site sets color-scheme, light-dark() does the same in one line: background-color: light-dark(#f4f1ea, #14161c);. It became Baseline widely available in November 2026 (webstatus.dev, checked November 30, 2026). With your own theme toggle, swap the variable under the toggle's selector, such as [data-theme="dark"].
Two checks for dark surfaces:
- Grain looks stronger on dark colors. The same tile that reads as faint paper on cream can look like noise on near-black. If it does, draw the tile smaller (
128px) or pick a calmer tile for the dark theme only. - Check text contrast on the darkest grain. The grain shifts the background a little lighter and darker than the base color. A text color that passes 4.5:1 against the base color with some room to spare stays readable; one that only just passes may not.
Photos need a different approach, a separate dark file. Our hero background guide covers that case.
File weight: what a texture costs
A repeated tile is downloaded once and drawn many times, so it costs far less than a full-screen photo. Here is what our 11 tiles weigh, fetched on November 30, 2026:
| Texture | WebP, 512 x 512 px | JPG, 1024 x 1024 px |
|---|---|---|
| Crumpled Paper | 6 KB | 138 KB |
| Rice Paper | 12 KB | 178 KB |
| Cotton Paper | 13 KB | 177 KB |
| Concrete | 14 KB | 221 KB |
| Worn Wall | 15 KB | 215 KB |
| Old Paper | 16 KB | 218 KB |
| Watercolor Paper | 24 KB | 212 KB |
| Recycled Paper | 34 KB | 266 KB |
| Kraft Paper | 37 KB | 277 KB |
| Linen | 48 KB | 256 KB |
| Fine Grain | 52 KB | 302 KB |
Three things stand out:
- WebP is the format to ship. The WebP tiles are 5 to 22 times smaller than the JPGs. Part of that is the smaller pixel size, part is the format. Keep the JPG as the master you edit.
- Busy grain costs bytes. Linen and Fine Grain have the most pixel-to-pixel variation of the set, and they are the heaviest. Crumpled Paper has the least and is the lightest. Noise does not compress well, in any format.
- One tile, many uses. The same 13 KB Cotton Paper file can sit behind a page, a card and a sidebar in three colors, and the browser downloads it once.
Serve the file with a long cache lifetime, since a texture almost never changes. Ours are sent with Cache-Control: public, max-age=31536000, immutable.
CSS-only textures: gradients, SVG noise and masks
You do not always need an image file. Three CSS-only options, and where each fits:
Repeating gradients draw geometric patterns: stripes, dots, grids, checks. They are tiny and stay sharp at any size, but they cannot draw paper fibers or concrete pores.
.dots {
background-color: #f4f1ea;
background-image: radial-gradient(#0002 1px, transparent 1px);
background-size: 16px 16px;
}SVG noise uses the feTurbulence filter inside an SVG data URI. The stitchTiles="stitch" attribute makes the noise tile without seams (MDN, stitchTiles). It gives an even film grain in a few hundred bytes. It does not give real paper character, and the browser has to render the filter itself, so test it on a slow phone before you put it behind a whole page. Our SVG to Base64 tool turns an SVG file into a data URI you can paste into CSS.
Masks texture the element itself, not its background. The Chrome team's modern web guidance uses mask-image with a repeating grunge tile, so the content looks worn because parts of it become see-through (Chrome for Developers). CSS masks have been Baseline widely available since June 2026 (webstatus.dev). Use them for a stamped headline or a worn badge, not for a page surface: a mask makes the text itself patchy, which hurts reading.
| Method | File | Looks like real material | Best for |
|---|---|---|---|
Grey tile + hard-light | 6 KB to 52 KB WebP | Yes | Page, card and section surfaces in any color |
| Repeating gradient | None | No | Dots, stripes, grids |
SVG feTurbulence | Under 1 KB inline | Partly: even grain only | A subtle film grain |
mask-image tile | One tile | Yes, on the element | Worn or stamped headings and badges |
Common problems and fixes
I can see a grid. The tile has one mark larger than the rest, or uneven light. On large plain areas, switch to a calmer tile. Our page notes that Worn Wall, Concrete and Crumpled Paper can show a faint repeat on very large areas, and suggests Cotton Paper or Fine Grain there. A smaller background-size also hides the repeat, because the eye cannot follow the grid as easily.
There is a line where the tiles meet. The tile is not seamless, or round stretched it. Check the CSS first, then the file: open it at 3 x 3 copies and look at the joins.
The grain is blurry. The tile is drawn larger than its pixels allow. Use half the file's pixel width or less as background-size, and never cover.
My color looks dirty. You used multiply, or the tile is darker than 50% grey on average. Switch to hard-light and use a tile balanced at 50% grey.
Everything is textured. Keep texture to one or two surfaces, such as the page and a feature section. Buttons, form fields and dense tables read better on flat color.
FAQ
How do I add a texture to a website background with CSS?
Which blend mode should I use for a paper texture?
What size should a seamless texture tile be?
How do I use a background texture with dark mode?
Is a background texture bad for page speed?
Can I make a texture with only CSS, no image?
Related posts