Reset styles
Overview
- Universal box-sizing and spacing
- Accessible link styles
- Built-in Canada.ca typography
- Unstyled lists
- Images scale to fit containers
- Unified form field styles
- Simplified table styles
- Accessible motion settings
Examples
Universal box-sizing and spacing
box-sizing: border-box. Padding and borders are included in the element’s total width and height. Margins and padding are reset to 0 for consistent spacing. * {
box-sizing: border-box;
margin: 0;
padding: 0;
}
Accessible link styles
<a href="#">
The default GCDS link styles are built into this link.
</a> Built-in Canada.ca typography
The default H3 heading typography styles are built into this heading.
The default text typography styles are built into this text.
<h3>
The default H3 heading typography styles are built into
this heading.
</h3>
<p>
The default text typography styles are built into this
text.
</p> Unstyled lists
- Default list item 1
- Default list item 2
- Default list item 3
<ul>
<li>Default list item 1</li>
<li>Default list item 2</li>
<li>Default list item 3</li>
</ul> Images scale to fit containers
max-width of 100%, preventing them from overflowing their container and maintaining their original aspect ratio.
<img src="/images/common/css-shortcuts/image-example.png" alt="A horizontal banner with purple flowers." /> Unified form field styles
input, select, and textarea) inherit the body’s font family and font size for consistency. <fieldset>
<legend>Shipping Address</legend>
<div>
<label for="shipping_name">Name</label>
<input type="text" name="shipping_name" id="shipping_name" />
</div>
<div>
<label for="shipping_street">Street</label>
<input type="text" name="shipping_street" id="shipping_street" />
</div>
</fieldset> Simplified table styles
| Last name | First name |
|---|---|
| Sayed | Fiza |
| Walker | Morgan |
<table>
<thead>
<tr>
<th class="b-sm">Last name</th>
<th class="b-sm">First name</th>
</tr>
</thead>
<tbody>
<tr>
<td class="b-sm">Sayed</td>
<td class="b-sm">Fiza</td>
</tr>
<tr>
<td class="b-sm">Walker</td>
<td class="b-sm">Morgan</td>
</tr>
</tbody>
</table> Accessible motion settings
@media (prefers-reduced-motion: reduce) query sets various properties like animation-duration, transition-duration, and scroll-behavior to minimal or default values, effectively disabling animations and transitions. @media (prefers-reduced-motion: reduce) {
*,
::before,
::after {
animation-delay: -1ms !important;
animation-duration: 1ms !important;
animation-iteration-count: 1 !important;
background-attachment: initial !important;
scroll-behavior: auto !important;
transition-duration: 0s !important;
transition-delay: 0s !important;
}
}