A CSS stripes generator creates a repeating two-color background by adding the stripe width and gap width to form one period, then encoding that period in a repeating-linear-gradient.
The CSS Stripes Generator makes that calculation visible: set the angle, colors, and two band widths, then copy a single background-image declaration. Its preview uses the exact repeating-linear-gradient value that goes to the clipboard, so the displayed pattern and copied CSS stay aligned.

The repeating pattern behind the stripes
The MDN repeating-linear-gradient reference and the W3C CSS Images specification describe color changes along a gradient line. When the line reaches the end of its final stop interval, that interval repeats along the gradient line in both directions. For a two-color stripe pattern, one cycle contains a stripe band followed by a gap band.
The generator writes four explicit color stops. The stripe color appears at the start and again at the stripe boundary, while the gap color appears at that same boundary and at the end of the period. Because adjacent stops share the same position, the browser switches directly between colors instead of blending them. Repeating each color in the stop list is therefore a deliberate way to create hard edges.
Worked example: a 10-pixel stripe and a 5-pixel gap produce a 15-pixel period because 10 + 5 = 15. With those values and a 45-degree angle, the declaration has this structure: background-image: repeating-linear-gradient(45deg, #222222 0px, #222222 10px, #eeeeee 10px, #eeeeee 15px);
Because the pattern is generated from pixel lengths rather than a raster image, it remains sharp on high-density screens and can cover large surfaces without downloading an asset. The preview is not a separate approximation: it applies the same gradient value that is copied.
Generate and test a usable stripe declaration
Use the generator to establish the pattern first, then validate it in the place where it will actually appear.
- Set the CSS angle for the stripe direction. Zero points upward along the gradient line, 90 points right, and a diagonal choice creates diagonal bands. Check the preview at the size of the real component rather than assuming its visible spacing matches the number entered.
- Choose the stripe and gap colors. Enter each as a complete six-digit hexadecimal value. The first color fills the stripe band and the second fills the gap. Use distinguishable colors, but remember that the generator does not calculate text contrast over the pattern.
- Adjust each band width and inspect the repeating period. Both widths must be finite and between 1 and 200 pixels. Their sum determines one cycle, so changing either value changes the repeat frequency and the balance between the colored stripe and gap.
- Copy the background-image declaration and test it in the actual component. Paste it into the relevant CSS rule, add a separate solid background-color fallback, and check text and control contrast across the full area. Zoom the page, inspect responsive sizes, and confirm that the pattern remains clear instead of shimmering or losing its stripe structure.
Inputs, validation, and fixed limits
The generator has a deliberately small set of inputs, and each accepted value has a defined role:
| Control | Accepted input | Effect |
|---|---|---|
| Angle | CSS degrees from 0 through 360 | Sets the gradient-line direction and therefore the stripe orientation. |
| Stripe color | Complete six-digit hexadecimal value | Fills the first band in each period. |
| Gap color | Complete six-digit hexadecimal value | Fills the second band in each period. |
| Stripe width | Finite value from 1 through 200 pixels | Sets the stripe's extent along the gradient line. |
| Gap width | Finite value from 1 through 200 pixels | Sets the gap's extent and completes the period. |
Empty or non-finite numeric inputs are errors, preventing an accidental zero-length period. The complete color format also keeps the output unambiguous. Validation confirms that the inputs form a valid two-color gradient; it does not judge whether the result is attractive, readable, or appropriate for a particular component.
Angle, projection, and apparent width
The angle is easiest to interpret through the gradient line. Stripe bands run across that line, so changing the angle changes both orientation and the spacing visible along the screen's horizontal and vertical axes.
| Angle setting | Gradient-line direction | Visible band direction |
|---|---|---|
| 0° | Upward | Horizontal bands |
| 90° | Right | Vertical bands |
| Diagonal setting | Diagonal | Diagonal bands with angle-dependent screen projection |
Stripe and gap widths are measured along the gradient line, not along the horizontal or vertical edge of the component. With a diagonal gradient, a fixed pixel width therefore occupies a different projected distance across the screen. The numeric value is a length on the gradient line, not a direct screen-axis measurement.
Preview the pattern at a representative element size and check the final container. This matters especially for narrow cards, responsive layouts, and areas where the stripe period aligns with surrounding edges or typography.
Integrating the copied declaration
The copied output uses background-image rather than the background shorthand. That distinction helps avoid resetting an existing background color, size, or position because those remain separate longhand properties. It also means the generated declaration configures the gradient image only; it does not include a fallback color, positioning, or sizing rules.
Add a solid fallback separately where appropriate. If the component uses multiple background layers, review the comma ordering carefully: the generated declaration supplies one gradient layer, and changing the order can change which layer appears in front. Replace literal colors or dimensions with established design tokens when those values belong to a broader design system.
All generation happens in the current tab without uploads, storage, login, or an added dependency. The resulting CSS is therefore easy to inspect, copy into a stylesheet, and review alongside the rest of the component's styles.
Contrast, scaling, and rendering checks
A stripe pattern does not provide a uniform background for text or controls. Contrast changes between the two colors, rapid stripes can create visual stress, and the generator does not test the contrast of text placed over the pattern.
- Create a stable reading surface. Put long text on a solid contained surface or add a solid overlay when the pattern remains visible behind it.
- Do not rely on pattern appearance alone. Stripe direction and color should not be the only signals used to communicate status or state.
- Watch very small bands. Fine patterns can produce moire, shimmer while scrolling, or unstable results under browser zoom and screenshots.
- Watch very large bands. At excessive sizes, the decoration may stop reading as a repeating stripe pattern at all.
Test the completed component under forced colors, dark themes, browser zoom, print output, screenshots, and motion contexts. Zooming is especially important because a preview that appears acceptable at the default size can become visually unstable when scaled.
If the background moves, respect reduced-motion preferences and measure paint behavior. A static decorative pattern is usually safer and clearer, especially around text, buttons, and frequently updated content.
What the generator leaves out
The generator intentionally omits transparent alpha, multiple intermediate colors, conic patterns, radial patterns, background positioning, and animation. Its output remains a focused, auditable repeating gradient made from two colors, one angle, and two pixel-based band widths.
Use it when that deterministic structure is enough. More elaborate alpha treatment, extra color transitions, other gradient geometries, positioning rules, or motion require additional CSS and another round of rendering and accessibility checks. The generator handles the core stripe calculation; production quality still depends on how the finished pattern behaves in its real container.
If you're weighing options, Text Shadow Generator Example: Create One CSS Shadow covers this in detail.