# Website spacing: the simple scale that stops a layout looking cheap

> Why generated pages feel cramped and uneven, and how to fix it with a spacing scale, steady section padding, grouping and max widths your agent can follow.

Canonical page: <https://aymu.dev/blog/spacing-makes-ai-sites-look-cheap>

Published 28 Nov 2026.

You can swap the fonts and fix the colors on a generated site, and it can still feel off. Often the reason is
spacing. The hero has 80 pixels of padding, the next section has 48, the one after that has 64. A heading sits as far
from the paragraph above it as from the paragraph it introduces. Cards in one grid have 24 pixels between them and 32
in the next. Text runs the full width of a wide monitor.

None of this shows up as one clear mistake. You just feel the page wasn't designed. People notice spacing least and
feel it most.

You don't need a better eye to fix it. You need a short list of rules: a scale, a rhythm, a grouping rule and a few
widths. Your coding agent can follow rules. It can't follow an eye.

## Why generated pages get spacing wrong

A model writes each section as its own small task. It picks `py-20` here and `py-16` there, because both seem fine.
Across a whole page, those choices don't agree. When you ask it to fix one section, the agent changes that section's
values without looking at the rest.

![Spacing values a model picks one section at a time, such as py-20, py-16, p-5, mt-7, gap-10 and an arbitrary 72px, with no shared decision.](/blog/figures/spacing-makes-ai-sites-look-cheap-1.png)

There's no shared decision for it to follow, so every edit adds a bit more mess. Make that decision once and write
it down.

## Use a spacing scale

A spacing scale is a short list of allowed values, and everything on the page uses one of them. Tailwind's default
spacing is already built on a 4-pixel step, which helps. But it allows almost any multiple, so narrow it down. A scale
like this works for most sites:

| Token | Pixels | Typical use                                   |
| ----- | ------ | --------------------------------------------- |
| 1     | 4      | Icon to label                                 |
| 2     | 8      | Inside small controls                         |
| 3     | 12     | Label to input                                |
| 4     | 16     | Between related lines, card padding on phones |
| 6     | 24     | Card padding, gap in a tight grid             |
| 8     | 32     | Between groups inside a section               |
| 12    | 48     | Heading block to content                      |
| 16    | 64     | Section padding on phones                     |
| 24    | 96     | Section padding on desktop                    |
| 32    | 128    | Before and after the hero                     |

The steps get bigger as they go up, on purpose. You can see the difference between 4 and 8, but not between 88 and
96. So large spaces don't need small steps.

In Tailwind terms, the scale above means you use `1, 2, 3, 4, 6, 8, 12, 16, 24, 32` and nothing else. No `p-5`, no
`mt-7`, no `gap-10`, no `py-[72px]`.

## Give sections a rhythm

Pick one top and bottom padding for normal sections and use it everywhere. Pick a larger one for the hero and the
final call to action if you want them to have more room. That's two values, not one per section.

```html
<!-- Every normal section -->
<section class="py-16 md:py-24">...</section>

<!-- Hero and closing CTA only -->
<section class="py-24 md:py-32">...</section>
```

If you separate sections by background tone, for example `bg-canvas` and `bg-surface` in turn, the padding still
stays the same. The rhythm comes from repeating it. Scrolling the page should feel like a steady beat, not a random
walk.

Inside a section, use the same structure each time: a heading block (eyebrow, heading, short intro), then a fixed
gap, then the content. If the heading block is always 48 pixels above the content, sections look related even when
their content differs.

## Group by proximity

This rule helps reading the most. Things that belong together sit closer to each other than to anything else.

![Before: one gap for everything, so the column reads as a flat list. After: the eyebrow sticks to the heading and the link has room of its own.](/blog/figures/spacing-makes-ai-sites-look-cheap-2.png)

A heading belongs to the paragraph below it, so the space below a heading is smaller than the space above it. A
label belongs to its input. A price belongs to its plan name. A caption belongs to its image.

Generated layouts often use one gap for everything, usually `space-y-4` on a whole column. That puts the heading as
far from its own text as from the block before it, and the page reads as a flat list.

Before:

```html
<div class="space-y-4">
  <p class="text-sm text-muted">Reports</p>
  <h2 class="text-3xl font-semibold">Weekly numbers, sent on Monday</h2>
  <p class="text-muted">One email with revenue, new customers and churn.</p>
  <a href="/reports" class="text-accent">See a sample report</a>
</div>
```

After:

```html
<div>
  <p class="text-sm text-muted">Reports</p>
  <h2 class="mt-2 text-3xl font-semibold">Weekly numbers, sent on Monday</h2>
  <p class="mt-4 text-muted">One email with revenue, new customers and churn.</p>
  <a href="/reports" class="mt-8 inline-block text-accent">See a sample report</a>
</div>
```

The eyebrow sticks to the heading, the paragraph sits close below, and the link has room of its own. Same elements,
clearer reading order.

## Set max widths

Text that spans a full desktop screen is hard to read. Your eye loses its place going back to the start of the next
line. Keep body text to about 60 to 75 characters per line. In Tailwind, `max-w-prose` is a good default for
paragraphs, and `max-w-2xl` or `max-w-3xl` works for a centered intro.

![Techy template hero: a centered headline, short subtext, two buttons and a wide product photo below](/blog/examples/techy.jpg)

*Example: [Techy](/templates/techy), a designed Astro template on Aymu.*

Set a separate, wider limit for the page container, and use it for every section:

```html
<div class="mx-auto max-w-6xl px-4 md:px-8">...</div>
```

One container width and one side gutter, everywhere. When section edges line up as you scroll, the page looks built
on a grid, even if you never drew one.

## Tell Claude to use only scale values

Write the scale into your `CLAUDE.md`. Short and specific works better than "use consistent spacing":

```markdown
## Spacing

- Allowed spacing steps: 1, 2, 3, 4, 6, 8, 12, 16, 24, 32 (Tailwind units).
  Never use other steps or arbitrary values like p-[18px].
- Sections: py-16 md:py-24. Hero and final CTA only: py-24 md:py-32.
- Container: mx-auto max-w-6xl px-4 md:px-8 on every section.
- Section heading block to content: mt-12.
- Space above a heading is larger than space below it. Don't use space-y-* on
  columns that mix headings and body text.
- Body text: max-w-prose.
```

Then run one cleanup pass on the existing pages:

```text
Read the Spacing rules in CLAUDE.md. Go through every .astro file in src/ and replace
spacing utilities (p, px, py, pt, pb, m, mx, my, mt, mb, gap, space-x, space-y) that use
values outside the allowed scale with the nearest allowed step. Make every section use the
section padding and container from the rules. Where a heading is closer to the block above
it than to its own text, fix the order of spacing. Don't change colors, fonts or copy.
Then list the files you changed.
```

Finish by checking the result yourself, at phone width and desktop width. The loop in
[screenshot, critique, fix](/blog/screenshot-critique-fix-loop) shows how to get the agent to check for you.

## A five-minute spacing check

Open your homepage and check:

1. Do all normal sections have the same top and bottom padding?
2. Do the left edges of every section line up?
3. Is each heading closer to its own text than to the block above?
4. Is any paragraph wider than about 75 characters per line?
5. Search your code for `-[`. Every hit is an arbitrary value outside your scale.

Once the spacing is right, the next fix is usually the top of the page:
[Hero section design: fix a generic AI hero, step by step](/blog/rewrite-a-generic-hero-section). If your palette is still
loose, start with [How to choose a website color palette (with Tailwind tokens)](/blog/website-color-palette).
