A CSS stripes generator creates a repeating two-color background whose pattern period equals the stripe width plus the gap width. For beginners, that turns a visual choice into five straightforward inputs: direction, two colors, and two band widths.
The CSS Stripes Generator handles the gradient calculation and provides a live preview before you copy one CSS declaration. Its preview uses the exact repeating-linear-gradient value sent to the clipboard, so the pattern you inspect is the pattern you apply. Everything runs in the current tab without uploads, storage, login, or an added dependency.

Generator controls and accepted values
Each control has a specific job. Understanding those jobs makes it easier to predict how changing one value will affect the result.
| Control | Accepted value | Purpose |
|---|---|---|
| Angle | 0°–360° | Sets the gradient-line direction. Zero degrees points upward along the gradient line, while 90 degrees points right. |
| Stripe color | Complete six-digit hexadecimal value | Sets the color of the first band in each period. |
| Gap color | Complete six-digit hexadecimal value | Sets the color of the space between stripe bands. |
| Stripe width | 1–200 pixels | Defines the stripe band along the gradient line. |
| Gap width | 1–200 pixels | Defines the gap band along the gradient line. |
The angle describes the gradient line rather than the visible path of a stripe. At zero degrees, the bands are horizontal; at 90 degrees, they are vertical; intermediate values create diagonal bands. Because stripe widths are measured along the gradient line, their visible spacing across the screen changes as the angle changes.
Both widths must be finite, positive numbers within the supported range. Empty or non-finite numeric entries are treated as errors rather than silently creating a zero-length period. Colors must use the complete six-digit hexadecimal format, so shorthand forms are not part of the accepted input.
Worked example: The pattern period is the stripe width plus the gap width. Substituting the inputs gives 10 px + 5 px = 15 px, so the pattern repeats every 15 px along the gradient line.
Build your first stripe background
Follow this four-step workflow to move from a blank preview to a tested CSS declaration.
- Set the CSS angle. Choose a value from 0° to 360°. Start with zero degrees for horizontal stripes or 90 degrees for vertical stripes, then try an intermediate angle for a diagonal effect. Check the preview at a representative element size because diagonal widths are projected differently across screen axes.
- Choose the stripe and gap colors. Enter a complete six-digit hexadecimal value for each color. Judge the pair as a repeating unit, paying particular attention to the hard boundary where the stripe changes into the gap.
- Adjust both band widths. Set the stripe and gap independently, with each value between 1 and 200 pixels. Inspect the reported repeating period and watch the boundary repeat across the preview. A diagonal band may look narrower on the screen because its configured width is measured along the gradient line.
- Copy and test the declaration. Copy the generated background-image declaration, paste it into the stylesheet for the real component, add a solid fallback, and inspect the result at normal size and under browser zoom. Confirm that the pattern remains clear and that any nearby text or controls remain usable.
The preview and copied declaration stay aligned because the tool applies the same repeating gradient to both. That makes the preview useful for tuning the direction, colors, widths, and period before the CSS reaches a page.
How the repeating gradient stays crisp
The generator writes four explicit color stops. The first color extends from zero to the stripe boundary, and the second color continues from that boundary to the end of the period. Both colors appear twice in the stop list so each boundary is hard rather than blended. Where two stops share the same position, the browser switches directly from one color to the other.
After the final color-stop interval, the browser repeats that interval in both directions along the gradient line. Pixel lengths keep the band widths and calculated period deterministic, so the preview does not depend on a raster image. The result remains sharp on high-density screens and can cover a large surface without downloading a separate texture asset.
This output follows the standard MDN repeating-linear-gradient reference and the gradient definitions in the W3C CSS Images specification. For a deeper walk-through of the four-stop structure, see CSS Stripe Pattern: Build It With Repeating Gradients.
Read diagonal widths correctly
A configured stripe width is a distance along the gradient line, not a promise about its horizontal or vertical footprint on the screen. When the gradient is diagonal, the same band is projected across both screen axes, and those projections change with the selected angle. The numeric width therefore should not be treated as a screen-axis measurement.
This distinction matters when estimating spacing or comparing the preview with a finished component. Test the background in the actual container, inspect several responsive sizes, and check the result under zoom. The repetition also follows the gradient line, so changing the angle changes both the direction of the bands and the direction in which the pattern advances.
Use the preview to tune the rhythm rather than assuming that two visually similar bands have the same screen-space width. If a diagonal pattern looks cramped, adjust the stripe or gap width and inspect the updated period at the intended size.
Apply the declaration without breaking the page
The copied output uses background-image rather than the background shorthand. That reduces the chance of accidentally resetting an existing background color, size, or position in the component. If the element already has several background layers, inspect their comma ordering carefully because the copied declaration adds another layer to that list.
Add a solid background color as a fallback, then replace literal colors or dimensions with established design tokens where appropriate. Keeping those decisions in the stylesheet makes the stripe easier to maintain without changing the gradient itself.
Patterned backgrounds can interfere with text and controls, and contrast varies across every boundary. Do not place long text directly over a strong pattern without a solid overlay or a contained reading surface. Direction and color should not be the only signals used to communicate status, either, because the pattern itself may be difficult to distinguish under different viewing conditions.
Test the final component in forced-colors mode, dark themes, zoomed views, print output, screenshots, and motion contexts. If the background moves, respect reduced-motion preferences and measure paint behavior; a static decorative pattern is usually safer and clearer. The goal is not merely to produce valid CSS, but to ensure the pattern remains understandable in the places where users will actually encounter it.
Know the deliberate generator limits
This tool focuses on an auditable, two-color repeating linear gradient. It intentionally omits transparent alpha, multiple intermediate colors, conic patterns, radial patterns, background positioning, and animation. The copied declaration also does not include the background shorthand, so fallback colors and other background properties remain separate implementation choices.
Very small bands can produce moire, shimmer while scrolling, or an unstable appearance under browser zoom and screenshots. Very large bands may stop reading as a repeating pattern at all. If either problem appears, revise the widths and inspect the pattern again in the final container instead of treating the initial preview as proof that it works everywhere.
Check the pattern before shipping it
Use this final review after applying the CSS:
- Confirm that the angle produces the intended band direction.
- Check that the stripe and gap colors remain distinct where they meet.
- Verify that both widths are inside the supported range and produce a usable period.
- Review the pattern at the actual element size and at zoomed sizes.
- Keep a solid fallback and protect long text with an overlay or contained surface.
- Test dark themes, forced colors, print output, and screenshots before release.