Sizing concepts

Foundation CSS implements a systematic approach to sizing through Spacing Units and Typography Scale. These concepts ensure consistency across your design system and provide a common language for designers and developers.

These sizing concepts are inspired by the BBC GEL guidelines, adapted to work seamlessly with modern web development practices.

Spacing Units

Spacing Units (SU) are a systematic way of applying predefined spacing dimensions to your designs. By using spacing units, you can create consistent layouts and simplify decision-making around margins, padding, and gaps.

Foundation CSS Spacing Variables

Foundation CSS uses two key variables to define its spacing system:

  • $su-full: 1008px - The maximum width of the design system's grid container
  • $su-step: 84px - The base spacing unit, calculated as $su-full ÷ 12

These variables are used throughout Foundation CSS for width, height, and spacing calculations, ensuring consistency across all components. The 12-column grid system provides a flexible foundation for responsive layouts while maintaining proportional relationships.

What are Spacing Units?

Spacing units provide a simple, consistent way to define space in your designs. They work similarly to how typography scales work for text sizing, giving you predefined values that work well together.

Foundation CSS defines space in rem units (relative to the root font size), making your designs compatible with browser text resizing and maintaining high accessibility standards.

Spacing Unit Scale

Spacing Unit Size in px Size in rem Usage
1 SU 4px 0.25rem Component spacing only
2 SU 8px 0.5rem Standard spacing
3 SU 12px 0.75rem Component spacing only
4 SU 16px 1rem Standard spacing
5 SU 20px 1.25rem Component spacing only
6 SU 24px 1.5rem Standard spacing
7 SU 32px 2rem Standard spacing
8 SU 40px 2.5rem Standard spacing
9 SU 48px 3rem Standard spacing
10 SU 56px 3.5rem Standard spacing
11 SU 64px 4rem Large spacing
12 SU 72px 4.5rem Large spacing
13 SU 80px 5rem Large spacing
14 SU 120px 7.5rem Extra large spacing
15 SU 160px 10rem Extra large spacing
16 SU 200px 12.5rem Extra large spacing

Exceptions to the Rule

1 SU, 3 SU, and 5 SU are exceptions to our consistent multiples of 8px pattern. These units are designed for component spacing only and should not be used for larger layout decisions such as spacing between content regions or arranging multiple components horizontally.

Using Spacing Units in CSS

Foundation CSS provides atomic classes for all spacing units:

Margin Classes

  • m0 to m16 - All sides
  • mt0 to mt16 - Top margin
  • mr0 to mr16 - Right margin
  • mb0 to mb16 - Bottom margin
  • ml0 to ml16 - Left margin
  • mx0 to mx16 - Horizontal margins
  • my0 to my16 - Vertical margins

Padding Classes

  • p0 to p16 - All sides
  • pt0 to pt16 - Top padding
  • pr0 to pr16 - Right padding
  • pb0 to pb16 - Bottom padding
  • pl0 to pl16 - Left padding
  • px0 to px16 - Horizontal padding
  • py0 to py16 - Vertical padding

Gap Classes

  • g0 to g16 - Grid and flexbox gaps

Typography Scale

Foundation CSS uses a systematic typography scale inspired by traditional printing terminology. This approach provides semantic naming that helps designers and developers communicate effectively about type choices.

Font Size Scale

Our typography scale uses names derived from traditional type measuring techniques, going back as far as 1582. Some names came from the type of book produced in that size - for example, Primer was used for religious books ordered by Henry VIII.

Size Name Usage Example
atlas Hero headlines, large display text Atlas Display
elephant Large headlines, feature titles Elephant Headline
imperial Major section headers Imperial Title
royal Page titles, important headings Royal Heading
foolscap Subsection headers Foolscap Subheading
canon Article titles, blog post titles Canon Article Title
trafalgar Article titles, section headers Trafalgar Section
paragon Primary headlines on indexes Paragon Headline
double-pica Sub headers, secondary headings Double Pica Subheader
great-primer Headline titles, subtitles Great Primer Title
body-copy Article text, main content Body copy text for articles and main content areas.
pica Small text, captions Pica text for captions and small details.
long-primer Secondary text Long primer for secondary information.
brevier Fine print, legal text Brevier for fine print and legal text.
minion Smallest text, footnotes Minion for footnotes and smallest text.

Font Weights

Foundation CSS provides the following font weight classes:

  • fw-light (300) - Light weight text
  • fw-normal (400) - Normal weight text
  • fw-medium (500) - Medium weight text
  • fw-semibold (600) - Semi-bold text
  • fw-bold (700) - Bold text
  • fw-extrabold (800) - Extra bold text
  • fw-black (900) - Black weight text

Responsive Typography

Foundation CSS automatically adjusts font sizes across different breakpoints to ensure optimal readability on all devices. The typography scale adapts to screen size while maintaining proportional relationships between different text sizes.

Typography Scale by Device

Inspired by the BBC GEL Typography guidelines, our type sizes are optimized for average screen densities and reading comfort under typical conditions. We size our type across four device categories to suit a range of devices and input methods:

  • Feature Phone: 0 - 319px (basic mobile devices)
  • Smartphone: 320 - 599px (standard mobile devices)
  • Tablet: 600px and above (tablets and large screens)
  • Desktop: 600px and above when hover/pointer:fine is available (desktop/laptop with mouse)

The sizes shown correspond to font-size/line-height and are in pixels, based on a baseline of 72 pixels per inch (ppi). Foundation CSS uses relative units (rem) to allow for browser text resizing and better accessibility.

Size Name Example Usage Feature Phone
0-319px
Smartphone
320-599px
Tablet
600px+
Desktop
600px+ hover
atlas Hero headlines, large display 78/84 96/104 192/208 140/148
elephant Large headlines, features 60/64 78/84 156/170 116/124
imperial Major section headers 50/54 64/72 124/136 96/104
royal Page titles, important headings 40/44 52/60 94/104 76/84
foolscap Subsection headers 32/36 40/44 72/80 56/60
canon Hero or blog post title 28/32 32/36 52/56 44/48
trafalgar Article title, section header 20/24 24/28 36/40 32/36
paragon Primary headline on indexes 20/24 22/26 28/32 28/32
double-pica Sub header 20/24 20/24 26/30 24/28
great-primer Headline title or subtitle 18/22 18/22 21/24 20/24
body-copy Article body copy 15/20 16/22 18/24 16/22
pica Index links, titles & headlines 15/20 16/20 18/22 16/20
long-primer Body copy & image captions 15/18 15/18 15/20 14/18
brevier Time stamps and bylines 14/16 14/18 14/18 13/16
minion Small header capitals 12/16 12/16 13/16 12/16

Best Practices

Spacing Unit Guidelines

✅ Do

  • Use one spacing unit at a time - Avoid stacking multiple spacing units together
  • Use spacing units only for space - Don't use them to define image sizes or other measurements
  • Choose appropriate units - Use 1 SU, 3 SU, and 5 SU only for component spacing
  • Be consistent - Use the same spacing units for similar elements across your design
  • Consider responsive behavior - Adjust spacing units at different breakpoints when needed

❌ Don't

  • Stack spacing units - Don't combine multiple units to create custom sizes
  • Use spacing units for non-spacing - Don't define image dimensions or border widths with spacing units
  • Use component units for layout - Don't use 1 SU, 3 SU, or 5 SU for larger layout decisions
  • Create custom spacing values - Stick to the predefined spacing unit scale
  • Ignore responsive considerations - Don't use the same spacing for all screen sizes

Typography Guidelines

✅ Do

  • Use semantic sizing - Choose font sizes based on content hierarchy and meaning
  • Maintain line length - Keep body copy to around 60 characters per line
  • Ensure contrast - Meet WCAG 2.0 AA contrast requirements
  • Use appropriate weights - Reserve heavier weights for headlines and interactive elements
  • Test readability - Verify text is readable across all target devices

❌ Don't

  • Adjust letter spacing - Don't modify tracking as it's optimized for readability
  • Use too many sizes - Stick to the predefined typography scale
  • Ignore line length - Don't create extremely long or short text lines
  • Use heavy weights for body text - Reserve bold weights for emphasis and headings
  • Forget about mobile - Ensure typography works well on small screens

Examples

Button Component with Spacing Units

HTML Structure

<button class="btn btn--primary">Primary Button</button>
<button class="btn btn--secondary">Secondary Button</button>

CSS with Design Tokens

.btn {
  padding: var(--su3) var(--su5);  /* 12px 20px */
  border-radius: var(--br-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn--primary {
  background-color: var(--blue);
  color: var(--light);
}

.btn--primary:hover {
  background-color: var(--blue-600);
}

Article Layout with Typography Scale

Article Title

Article subtitle or description

This is the main article content using the body-copy font size. The typography scale ensures consistent hierarchy and readability across different screen sizes.

Section Heading

Section content continues with the same body-copy size, maintaining consistent reading experience throughout the article.

Published on January 1, 2024

Card Component with Combined Concepts

Card Title

Card description using body-copy typography.

Another Card

Consistent spacing and typography across cards.

Third Card

Maintaining visual harmony with spacing units.

Acknowledgments

The spacing unit and typography concepts in Foundation CSS are inspired by the BBC GEL (Global Experience Language) guidelines. We extend our gratitude to the BBC UX&D team for their pioneering work in creating systematic, accessible design systems.

For more information about the original concepts, please refer to:

CSS Variables

#

Spacing Units as CSS Variables

All spacing units are exposed as CSS custom properties for use in custom components:

:root {
  --su1: 0.25rem;   /* 4px */
  --su2: 0.5rem;    /* 8px */
  --su3: 0.75rem;   /* 12px */
  --su4: 1rem;      /* 16px */
  --su5: 1.25rem;   /* 20px */
  --su6: 1.5rem;    /* 24px */
  --su7: 2rem;      /* 32px */
  --su8: 2.5rem;    /* 40px */
  --su9: 3rem;      /* 48px */
  --su10: 3.5rem;   /* 56px */
  --su11: 4rem;     /* 64px */
  --su12: 4.5rem;   /* 72px */
  --su13: 5rem;     /* 80px */
  --su14: 7.5rem;   /* 120px */
  --su15: 10rem;    /* 160px */
  --su16: 12.5rem;  /* 200px */
  --su-full: 63rem; /* 1008px */
  --su-step: 5.25rem; /* 84px */
}

/* Use in custom components */
.my-component {
  padding: var(--su4);
  margin-bottom: var(--su6);
  gap: var(--su3);
}

.my-container {
  max-width: var(--su-full);
  padding: var(--su4);
}

/* Media queries need SCSS variables (evaluated at build-time) */
@media (min-width: 1008px) {  /* $breakpoints.md */
  .my-container {
    padding: var(--su6);
  }
}

SCSS Variables (Build-time)

Override SCSS variables before importing to customize the spacing scale:

@use "@enodo/foundation-css" with (
  $spacing-units: (
    1: 4px, 2: 8px, 3: 12px, 4: 16px,
    5: 20px, 6: 24px, 7: 32px, 8: 40px,
    // ... customize as needed
  ),
  $su-full: 1008px
);