Spacing & Sizing for AI Coders | SheCodes
Beginner 5 min read

Spacing & Sizing for AI Coders

The #1 difference between amateur and professional websites. Master whitespace and your sites will instantly look better.

In this chapter

  • Why spacing is the #1 difference between amateur and pro sites
  • What padding, margin, and gap really mean
  • How to give AI exact spacing instructions
  • A simple spacing system you can reuse anywhere
Live example

The Golden Rule

When in doubt, add more space.

Beginners always cram things together. Professional designs breathe. White space is not wasted space: it guides the eye and creates hierarchy.

The 4px / 8px Grid System

All spacing should be multiples of 4px (or 8px for simplicity). This creates consistent, harmonious layouts.

Live example
0px
No space
2px
Hairline gaps
4px
Tight inner padding
6px
Small badges, chips
8px
Compact elements
12px
Button padding (vertical)
16px
Card padding, form gaps
20px
Section inner padding
24px
Card padding (comfortable)
32px
Section padding
40px
Large section gaps
48px
Page section spacing
64px
Hero padding
80px
Large section breaks
96px
Page top/bottom padding

Padding vs Margin vs Gap

Padding Space inside an element. Between the border and the content.
Content

← padding →

Margin Space outside an element. Between this element and its neighbors.
Element A

↕ margin

Element B
Gap Space between items in a flex or grid container. The modern way.
A
B
C

← gap →

Spacing Patterns to Know

These are the most common spacing patterns in professional websites. Tell your AI tool what you want and it will handle the details.

Page Container Centered content with responsive side padding. Use on every page.
pad
pad
Section Spacing Vertical padding between major page sections.
space
Section Header Space below section titles before content starts.
gap
Card Grid Responsive grid with comfortable gaps.
Card Padding Internal card padding, comfortable but not wasteful.
padding
Button Padding Horizontal is always more than vertical.
Buttontopside
Form Fields Consistent spacing between form fields.
Text Content Optimal reading width (~65 chars) with relaxed line height.
Navbar 64px tall navbar with responsive horizontal padding.
pad
pad
Stack (vertical) Consistent vertical spacing between stacked items.

Max Widths & Container Sizes

Live example
384px
Login forms, small modals
448px
Forms, dialogs, narrow content
512px
Medium forms, search bars
576px
Content sections, medium modals
672px
Blog content, articles
768px
Wide articles, documentation
1024px
Dashboard content areas
1280px
Full page layouts (standard)
65ch (~650px)
Optimal reading width for text

Common Element Sizes

Navbar height 64px Standard height. 56px for a more compact look.
Icon (in button) 16-20px Should match the size of the button text.
Icon (standalone) 20-24px Standalone icons like social media links.
Avatar (small) 32px Comments, compact lists.
Avatar (medium) 40px Navbar, cards, standard use.
Avatar (large) 64px Profile pages, headers.
Logo icon 32px In navbar next to site name.
Card icon 40-48px Feature cards, section icons.
Floating button 56px Standard floating action button.
Touch target 44px minimum Minimum size for anything tappable on mobile.
Corner rounding 8-12px Modern, friendly look. Larger for cards.
Border width 1px Subtle borders. 2px for emphasis.

How to Describe Spacing to AI

Sections feel cramped

“Add more breathing room between sections. They feel too close together. Make the vertical spacing generous.”

Cards feel tight

“The cards need more internal padding so the content isn't jammed against the edges. Also increase the space between the cards.”

Content is too wide

“The content stretches too wide on big screens. Center it and limit the max width so it looks good on all screen sizes.”

Text is hard to read

“The text lines are too long to read comfortably. Limit the paragraph width so each line is about 65 characters.”

Prompt This

Copy-paste these prompts into your AI tool to apply what you just learned.

APPLY CONSISTENT SPACING

“Review my page layout and apply consistent spacing. Use 8px increments: 16px for tight gaps, 24px for related items, 48px between sections. Make sure padding and margins follow the same scale throughout.”

ADD BREATHING ROOM

“My page looks cramped. Add breathing room between sections and components using a consistent spacing scale. Increase padding inside cards, add more space between the heading and content, and make sure nothing feels jammed together.”

SET UP PAGE CONTAINERS

“Set up a centered page container with a max-width of [1280px / 1024px / 768px]. Add responsive horizontal padding: 16px on mobile, 24px on tablet, 48px on desktop. Center the container on the page.”

Frequently Asked Questions

How much space should I put between elements?

Use a consistent spacing scale. Most design systems use multiples of 4px or 8px. For example: 8px between related items, 16px between groups, 32-48px between sections. Ask your AI tool to set up a spacing system so everything stays consistent.

Why does my page feel cramped even though the content is good?

You probably need more whitespace. Beginners tend to pack elements too tightly. Add more padding inside cards, more margin between sections, and more line height in paragraphs. Whitespace makes your content easier to read.

What's the difference between margin and padding?

Padding is the space inside an element (between its border and its content). Margin is the space outside an element (between it and neighboring elements). Think of padding as the cushion inside a box, and margin as the gap between boxes.