Heniflow
All articles
02Design guide
Written by
Heni
Published
Reading time
8 min
  • Web design
  • UI/UX
  • 8pt grid
  • Spacing
  • Accessibility

Website designbest practices.

A practical guide to the rules that make websites feel professional: the 8-point grid, spacing, padding and margin, white space, typography, color, accessibility and performance.

8 · 16 · 24 · 32 · 48 · 64

Good websites rarely feel good by accident. Behind most clean, calm interfaces there is a small set of rules applied consistently: a spacing system, a type scale, a grid, and a few accessibility and performance targets. This guide collects the best practices I use on every project, with the numbers to back them up.

1. The 8-point grid

The 8-point grid means every size and space in your interface is a multiple of 8: 8, 16, 24, 32, 48, 64 and so on. Use 4 for small adjustments, like the gap between an icon and its label.

Why 8? It divides cleanly into the most common screen sizes, it scales without half pixels at 1.5x and 2x densities, and, most importantly, it removes guesswork. Instead of debating whether a gap should be 13 or 15 pixels, you choose between 12 and 16.

TokenValueTypical use
space-14pxIcon to label, tight inline gaps
space-28pxRelated items inside a component
space-312pxCompact padding, list items
space-416pxDefault padding, form field gaps
space-624pxCard padding, gaps between groups
space-832pxBetween components
space-1248pxBetween blocks inside a section
space-1664pxSection padding on mobile
space-2496pxSection padding on desktop
space-32128pxLarge hero and section breaks
CSS
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;
}

.card {
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
}

2. Padding, margin and gap

  • Padding is the space inside an element, between its border and its content. Use it to give a button, card or section its own breathing room.
  • Margin is the space outside an element, pushing other elements away. Use it sparingly, and prefer one direction (for example, only margin-top) so spacing does not collapse in surprising ways.
  • Gap is the space between children of a flex or grid container. In modern layouts, gap is usually the best choice: the parent controls the rhythm, and no child needs to know about its neighbours.

3. White space is not empty space

White space (or negative space) is the area around and between elements. It is the single biggest difference between interfaces that feel premium and interfaces that feel crowded.

  • Macro white space separates big blocks: sections, columns, the margins of the page. Generous section padding (64px on mobile, 96 to 128px on desktop) tells visitors a new idea is starting.
  • Micro white space lives inside components: line height, letter spacing, the padding of a button. It decides whether text is comfortable to read.
  • Proximity (a Gestalt principle) says that elements close together are seen as related. Use space, not lines and boxes, to group content wherever you can.
  • One idea per section. If a section needs a second headline, it probably needs to be two sections.

4. Layout grids and alignment

  • Use a 12-column grid on desktop (it divides into 2, 3, 4 and 6), 8 columns on tablet and 4 on mobile.
  • Keep gutters between 16 and 32px, and page margins of at least 16px on mobile and 24 to 80px on desktop.
  • Cap the content width at around 1200 to 1440px so lines and layouts do not stretch on large screens.
  • Align everything to something. Every edge should line up with another edge or a grid line. Misalignment of a few pixels is what makes a layout feel slightly off without anyone knowing why.
  • Prefer left-aligned text for anything longer than two lines. Centered text is fine for short headlines.

5. Typography

RuleRecommended value
Body text size16px minimum (17 to 18px for long reading)
Body line height1.4 to 1.6
Heading line height1.0 to 1.2
Line length45 to 75 characters, about 66 is ideal
Type scale ratio1.2 to 1.333 (for example 16, 20, 24, 32, 40, 48)
TypefacesOne or two families, a few weights
Large headingsSlightly negative letter spacing (-0.02em to -0.05em)

Use fluid type for headings so they scale smoothly between mobile and desktop instead of jumping at breakpoints:

CSS
h1 {
  /* 40px on small screens, up to 72px on large ones */
  font-size: clamp(2.5rem, 1.6rem + 4vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

p {
  font-size: 1rem;      /* 16px */
  line-height: 1.6;
  max-width: 66ch;      /* comfortable line length */
}

6. Visual hierarchy

  • Create hierarchy with size, weight, color and position, in that order. You rarely need all four at once.
  • Give each screen one primary action. Secondary actions should look secondary (outlined or text buttons).
  • Use contrast in tone for supporting text: a softer color for labels and metadata lets headlines and actions stand out.
  • Design for scanning. Most visitors read headlines, the first words of paragraphs and buttons. Make those carry the message on their own.

7. Color and contrast

  • Follow the 60-30-10 rule: about 60% dominant neutral, 30% secondary color, 10% accent for actions and highlights.
  • Meet WCAG AA contrast: at least 4.5:1 for body text, and 3:1 for large text (24px, or 18.66px bold) and for UI components like input borders and icons.
  • Never rely on color alone to carry meaning. Pair an error color with an icon or a message.
  • Define colors as tokens (primary, surface, text, muted, border) instead of raw hex values in components, so the system stays consistent and themeable.

8. Buttons and touch targets

GuidelineMinimum target size
Apple Human Interface Guidelines44 × 44 pt
Material Design48 × 48 dp
WCAG 2.2 (AA, success criterion 2.5.8)24 × 24 CSS px
  • Design every interactive element with all its states: default, hover, focus, active, disabled and loading.
  • Keep a visible focus style. Removing the outline without a replacement makes your site unusable with a keyboard.
  • Write button labels as actions: "Start a project" beats "Submit".
  • Leave at least 8px between adjacent targets so people do not tap the wrong one.

9. Consistency and components

  • Use one corner radius scale (for example 4, 8 and 16px) and stick to it.
  • Use one icon set at fixed sizes (16, 20, 24px) with a consistent stroke width.
  • Build components once (buttons, inputs, cards) and reuse them. A design system is just consistency made reusable.
  • Keep the same thing in the same place: navigation, primary actions and footers should not move between pages.

10. Forms

  • Put labels above inputs, and never use the placeholder as the only label: it disappears as soon as someone types.
  • Use a single column for most forms. It is faster to complete than multiple columns.
  • Ask for as little as possible. Every extra field lowers completion.
  • Validate inline and kindly: say what is wrong and how to fix it, next to the field.
  • Use the right input types (email, tel, number) so mobile keyboards help instead of getting in the way.

11. Responsive design

  • Design mobile first, then add layout as space allows. It forces you to prioritise content.
  • Choose breakpoints by content, not by device names. Break the layout where it stops working.
  • Scale spacing as well as type: a 128px section padding on desktop might be 64px on mobile.
  • Test on real devices, including small phones and large desktop screens.

12. Images and performance

A beautiful site that loads slowly is not a beautiful experience. Google measures real-world experience with Core Web Vitals, and these are the targets to hit:

MetricWhat it measuresGood
LCP (Largest Contentful Paint)How fast the main content appears2.5 s or less
INP (Interaction to Next Paint)How fast the page responds to input200 ms or less
CLS (Cumulative Layout Shift)How much the layout jumps while loading0.1 or less
  • Serve modern formats (AVIF or WebP) and the right size for each screen.
  • Always set width and height (or an aspect ratio) on images and videos so the layout does not shift.
  • Lazy load anything below the fold, and preload the hero image.
  • Limit web fonts to the weights you actually use.

13. Accessibility

  • Use semantic HTML: one h1 per page, headings in order, real buttons and links.
  • Write alt text for meaningful images, and an empty alt for decorative ones.
  • Make everything work with a keyboard, in a logical order.
  • Respect prefers-reduced-motion for people who are sensitive to animation.
  • Accessible design is not a separate feature. It is simply good design that works for more people.

14. Motion

  • Keep UI transitions short: 150 to 300ms for most interactions, up to about 500ms for large movements.
  • Use ease-out curves for elements entering the screen, so they arrive quickly and settle gently.
  • Animate with purpose: to show where something came from, confirm an action, or guide attention. Never only to decorate.
  • Animate transform and opacity instead of layout properties, so motion stays smooth.

The checklist

  1. 01Every space and size comes from an 8-point scale.
  2. 02Space inside groups is smaller than space between groups.
  3. 03Sections have generous, consistent padding.
  4. 04Content is aligned to a grid with a max width.
  5. 05Body text is 16px or more, line height 1.4 to 1.6, 45 to 75 characters per line.
  6. 06Each screen has one clear primary action.
  7. 07Text and UI meet WCAG AA contrast.
  8. 08Touch targets are at least 44px (24px absolute minimum).
  9. 09Every interactive element has hover, focus and disabled states.
  10. 10Forms have visible labels and inline validation.
  11. 11Images have dimensions, modern formats and alt text.
  12. 12LCP, INP and CLS are in the green.
  13. 13Motion is short, purposeful and respects reduced motion.

None of these rules make a website memorable on their own. Ideas, personality and craft do that. But these rules remove the friction that stops people from noticing the ideas in the first place.

Have a project in mind?

Bring it.I engineer it.