CSS Horizontal Stripes Background
Horizontal stripes in pure CSS with one repeating-linear-gradient. Set stripe height and the gap between lines live, then copy the CSS or Tailwind classes.
.bg-horizontal-stripes {
--bg: #cc3f47;
--fg: #df878c;
--size: 8px;
--gap: 24px;
background-color: var(--bg);
background-image: repeating-linear-gradient(var(--fg) 0 var(--size), transparent 0 calc(var(--size) + var(--gap)));
}<div class="
[--bg:#cc3f47]
[--fg:#df878c]
[--size:8px]
[--gap:24px]
[background-color:var(--bg)]
[background-image:repeating-linear-gradient(var(--fg)_0_var(--size),_transparent_0_calc(var(--size)_+_var(--gap)))]
"></div><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Horizontal Stripes — CSS background</title>
<style>
html, body { height: 100%; margin: 0; }
.bg-horizontal-stripes {
--bg: #cc3f47;
--fg: #df878c;
--size: 8px;
--gap: 24px;
background-color: var(--bg);
background-image: repeating-linear-gradient(var(--fg) 0 var(--size), transparent 0 calc(var(--size) + var(--gap)));
}
</style>
</head>
<body class="bg-horizontal-stripes"></body>
</html>Save the pattern as an image, with your current colors and settings.
Horizontal Stripes in other colors
Click a color to try it in the preview above, then copy the code.
Browse by color: Red · Orange · Yellow · Green · Teal · Blue · Purple · Pink
How the horizontal stripes pattern works
Horizontal stripes come from a single repeating-linear-gradient(). With no angle given, the gradient runs top to bottom, so each band of color lies flat across the element.
One repeat is a stripe and a gap: --fg from 0 to --size, then transparent until --size + --gap, letting --bg show through. Writing transparent 0 starts the second stop exactly where the first ends, which gives a crisp edge instead of a blur. Because the gradient repeats itself, there is no tile and no seam.
Set --size and --gap separately to get very different looks. Equal values make classic awning stripes. A 1–2px --size with a larger --gap gives thin horizontal lines, like a ruled page or a scanline effect.
Horizontal stripes suit banners, nautical and retro themes, and subtle card backgrounds. The Tailwind tab gives the same stripes as arbitrary-property classes for Tailwind v4.