CSS Triangle Background

A triangle background in pure CSS: rows of equilateral triangles from one conic-gradient wedge per tile. Set triangle size and colors live, then copy it.

#cc3f47
#df878c
48px
.bg-triangles {
  --bg: #cc3f47;
  --fg: #df878c;
  --size: 48px;
  background-color: var(--bg);
  background-image: conic-gradient(from 150deg at 50% 0, var(--fg) 60deg, transparent 0);
  background-size: var(--size) round(calc(var(--size) * 0.866), 1px);
}
<div class="
  [--bg:#cc3f47]
  [--fg:#df878c]
  [--size:48px]
  [background-color:var(--bg)]
  [background-image:conic-gradient(from_150deg_at_50%_0,_var(--fg)_60deg,_transparent_0)]
  [background-size:var(--size)_round(calc(var(--size)_*_0.866),_1px)]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Triangles — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-triangles {
      --bg: #cc3f47;
      --fg: #df878c;
      --size: 48px;
      background-color: var(--bg);
      background-image: conic-gradient(from 150deg at 50% 0, var(--fg) 60deg, transparent 0);
      background-size: var(--size) round(calc(var(--size) * 0.866), 1px);
    }
  </style>
</head>
<body class="bg-triangles"></body>
</html>

Save the pattern as an image, with your current colors and settings.

Triangles 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 triangles pattern works

Each triangle is a wedge of a conic-gradient(). The gradient starts at the top center of the tile (at 50% 0) and sweeps around that point. Starting from 150deg, it paints --fg for 60 degrees, then turns transparent, which leaves a downward-opening wedge with its point at the top.

The tile size does the rest. A 60° wedge cut off by the bottom of the tile is an equilateral triangle exactly when the tile is 0.866 (√3 ÷ 2) times as tall as it is wide. So background-size: var(--size) round(calc(var(--size) * 0.866), 1px) makes each triangle’s base exactly one tile wide, and neighbors touch at the corners. round() snaps the height to whole pixels so no thin seam shows between rows. The background between them forms a second set of upside-down triangles.

--size sets the width of each triangle. Even values keep the edges crisp.

Use triangles for geometric hero sections, tech and gaming themes, sports pages and bold section dividers. The Tailwind tab outputs the same gradient for Tailwind v4.