GC Design System CSS Shortcuts
GC Design System Start to use Page templates overview Basic page Components overview Breadcrumbs Button Card Checkboxes Container Date input Date modified Details Error message Error summary Fieldset File uploader Footer Grid Header Heading Icon Input Language toggle Link Notice Pagination Radios Screenreader-only Search Select Side navigation Signature Stepper Text Textarea Theme and topic menu Top navigation CSS shortcuts overview Reset styles Responsive layout State Box sizing Container sizing Display Overflow Position Visibility Font Font family Font size Font style Font weight Line height Link colour Link size Link text decoration List style Text align Text colour Text overflow Text transform Word break Margin Padding Align content Align items Align self Flex Flex direction Flex grow Flex shrink Flex wrap Gap Grid columns Grid rows Justify content Justify items Justify self Order Place content Place items Place self Background colour Border colour Border radius Border style Border width Icon names Icon size Image Cursor Pointer events Transition Styles overview Design tokens Colour tokens Spacing tokens Typography tokens Contact us Get involved Find a demo

Margin

The margin class sets the margin property. It controls the space outside the border of an element.

Logical properties adapt to the writing mode and text direction. Instead of literal directions like "left", "right", "top", or "bottom", they use flow-relative terms.

This flexibility prepares layouts for internationalization without needing manual adjustments for different text directions.

Overview

The value can be either one of our predefined spacing tokens (0 - 1250) or auto.

CSS Shortcut class Applied style Legacy property
m-<value>
margin: var(--gcds-spacing-<value>);
margin
mt-<value>
margin-block-start: var(--gcds-spacing-<value>);
margin-top
mb-<value>
margin-block-end: var(--gcds-spacing-<value>);
margin-bottom
ms-<value>
margin-inline-start: var(--gcds-spacing-<value>);
margin-left
me-<value>
margin-inline-end: var(--gcds-spacing-<value>);
margin-right
mx-<value>
margin-inline: var(--gcds-spacing-<value>);
margin-left + margin-right
my-<value>
margin-block: var(--gcds-spacing-<value>);
margin-top + margin-bottom

Examples

All sides
m-<value>

This element has no margin on all sides.

<p class="m-0">
  This element has no margin on all sides.
</p>

Top side
mt-<value>

This element lets the browser automatically calculate the margin on the top side.

<p class="mt-auto">
  This element lets the browser automatically calculate the margin on the top side.
</p>

Bottom side
mb-<value>

This element has a margin of --gcds-spacing-900 on the bottom side.

<p class="mb-900">
  This element has a margin of --gcds-spacing-900 on the bottom side.
</p>

Left side
ms-<value>

This element has no margin on the left side.

<p class="m-900 ms-0">
  This element has no margin on the left side.
</p>

Right side
me-<value>

This element has no margin on the right side.

<p class="m-900 me-0">
  This element has no margin on the right side.
</p>

Horizontal sides
mx-<value>

This element is horizontally centred by letting the browser automatically calculate the margin.

<p class="container-md mx-auto">
  This element is horizontally centred by letting the browser automatically calculate the margin.
</p>

Vertical sides
my-<value>

This element has a margin of --gcds-spacing-900 on the top and bottom sides.

<p class="my-900">
  This element has a margin of --gcds-spacing-900 on the top and bottom sides.
</p>

Conditional styling Apply this style to specific screen sizes Use a responsive layout prefix to apply this class only to a specified screen size. The available breakpoints are:

  • xs: > 480px
  • sm: > 640px
  • md: > 768px
  • lg: > 1024px
  • xl: > 1280px
  
<div class="xs:m-300 ...">
  ...
</div>
  

Learn more about the responsive layout prefix.

2025-10-01