CSS Background Image Generator
WM-107Pick a gradient or a pattern, set two colors and the size, and copy the CSS. Everything is drawn by the browser from the CSS shown, so there are no image files to host.
Runs in your browser. Nothing is uploaded.
Background
Preview and CSS
| background-color | #4f46e5 |
|---|---|
| background-image | linear-gradient(135deg, #4f46e5, #ec4899) |
CSS
.box {
background-color: #4f46e5;
background-image: linear-gradient(135deg, #4f46e5, #ec4899);
} How to use it
- Choose a type: linear, radial or conic gradient, stripes, checkerboard, dots or grid.
- Pick the first and second color.
- Set the angle for linear, conic and stripes, or the pattern size for stripes, checkerboard, dots and grid.
- Press Copy and paste the rule onto any element.
Gradients and patterns in plain CSS
Gradients are CSS images, so they go in background-image and need no file. The three gradient types differ in direction: linear blends along a line at the angle you set, radial blends outward from the center, and conic sweeps around the center like a color wheel. The conic version returns to the first color so there is no visible seam.
How the patterns work
Patterns repeat a small tile. Stripes use repeating-linear-gradient with hard color stops. The checkerboard uses repeating-conic-gradient on a tile twice the square size. Dots and grid lines are gradients drawn over the second color and repeated with background-size. Fields that do not apply to the chosen type, such as the angle for a grid, are ignored.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Grid line width must be smaller than the pattern size. | The grid line is as wide as the tile, which would fill it. | Lower the line width or raise the pattern size. |
Questions people ask
Can I use my own image as the background?
No. This tool covers gradients and patterns made of CSS only, so nothing is loaded from a web address. To use a picture, add background-image: url(your-file) yourself in your stylesheet.
How do I change the size of the checkerboard squares?
Use the pattern size field. It is the width of one square, and the tool writes a tile twice that size so the two colors alternate in both directions.
What is the difference between background and background-image?
background-image sets only the image layer. The background shorthand also resets color, size, position and repeat. The checkerboard is written with the shorthand because its size and position are part of the same rule.
Will the gradient work in all browsers?
Linear and radial gradients have long been supported without prefixes. Conic gradients and the two-position color stops used for stripes are newer, so check your browser support targets if you must support very old browsers.
Why are the stripes hard-edged?
The two colors meet at the same position, so there is no blend between them. That is how stripes are made. For a soft blend use the linear gradient type instead.
How do I add more than two colors?
Copy the CSS and add more color stops to the gradient function yourself, for example another color and percentage before the closing bracket. This tool writes two-color gradients.
About this tool
Generates gradients and repeating patterns using only CSS, with no image files and no network requests. Linear, radial and conic gradients blend your two colors; the conic gradient returns to the first color so it has no seam. Stripes use repeating-linear-gradient with hard stops, the checkerboard uses repeating-conic-gradient, and dots and grid lines use radial and linear gradients over the second color. Fields that do not apply to the chosen type are ignored. Background images from a web address are not supported.