CSS Lined Paper Background

Lined notebook paper in pure CSS: ruled lines plus a margin line, made from two linear gradients. Set line spacing and margin live, then copy CSS or Tailwind.

#223b8c
#7585b7
28px
64px
.bg-lined-paper {
  --bg: #223b8c;
  --fg: #7585b7;
  --size: 28px;
  --margin: 64px;
  background-color: var(--bg);
  background-image:
    linear-gradient(90deg, transparent calc(var(--margin) - 1px), var(--fg) calc(var(--margin) - 1px) calc(var(--margin) + 1px), transparent calc(var(--margin) + 1px)),
    repeating-linear-gradient(transparent 0 calc(var(--size) - 1px), var(--fg) calc(var(--size) - 1px) var(--size));
}
<div class="
  [--bg:#223b8c]
  [--fg:#7585b7]
  [--size:28px]
  [--margin:64px]
  [background-color:var(--bg)]
  [background-image:linear-gradient(90deg,_transparent_calc(var(--margin)_-_1px),_var(--fg)_calc(var(--margin)_-_1px)_calc(var(--margin)_+_1px),_transparent_calc(var(--margin)_+_1px)),_repeating-linear-gradient(transparent_0_calc(var(--size)_-_1px),_var(--fg)_calc(var(--size)_-_1px)_var(--size))]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Lined Paper — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-lined-paper {
      --bg: #223b8c;
      --fg: #7585b7;
      --size: 28px;
      --margin: 64px;
      background-color: var(--bg);
      background-image:
        linear-gradient(90deg, transparent calc(var(--margin) - 1px), var(--fg) calc(var(--margin) - 1px) calc(var(--margin) + 1px), transparent calc(var(--margin) + 1px)),
        repeating-linear-gradient(transparent 0 calc(var(--size) - 1px), var(--fg) calc(var(--size) - 1px) var(--size));
    }
  </style>
</head>
<body class="bg-lined-paper"></body>
</html>

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

Lined Paper 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 lined paper pattern works

Lined paper is two gradients stacked. The bottom layer is a repeating-linear-gradient() that stays transparent for --size minus one pixel, then draws a 1px --fg line. It repeats down the page, so every --size pixels you get a ruled line.

The top layer draws the margin. It’s a plain linear-gradient(90deg, …) with no repeat: transparent up to --margin, a 2px line in --fg, then transparent again. Because it isn’t repeated, there’s only one vertical line, set --margin pixels from the left edge. Set --margin to 0 to hide it.

--size sets the line spacing. Around 24–32px matches real notebook paper next to body text. To line text up with the rules, set the text’s line-height to the same value as --size.

Use it for note-taking and journaling apps, school or study themes, letters and to-do lists. The Tailwind tab outputs the same two layers for Tailwind v4.