Web Style Guide

Relative Units

Use relative units whenever possible.

html { font-size: 100% } p { font-size: 1em } @media (min-width: 64em) { html { font-size: 112.5%; } }

Containers

The container, also known as the wrapper, is an HTML element that encloses one or more other elements. It allows for grouping elements semantically, cosmetically, or in layout.

html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } .container { max-width: 67rem; padding-left: 1.5rem; padding-right: 1.5rem; }

Font Sizing

Use a modular scale to help you decide on the font-size of your elements. Modular scale refers to a series of harmonious numbers that relate to one another in a meaningful way.

A modular scale in action.

Responsive Modular Scale

A single modular scale will rarely look good on all resolutions. To remedy this, different scales can be used depending on the resolution of the viewer's device.

//Sass responsive modular scale /* * Modular scale * http://www.modularscale.com/?1.25&em&1.33&web&text */ $type-scale-large: ( h1: 3.911rem, h2: 2.941rem, h3: 2.211rem, h4: 1.663rem, p: 1.25rem ); /* * Modular scale * http://www.modularscale.com/?1.25&em&1.25&web&text */ $type-scale-medium: ( h1: 3.052rem, h2: 2.441rem, h3: 1.953em, h4: 1.563rem, p: 1.25rem, ); /* * Modular scale * http://www.modularscale.com/?1.1&em&1.25&web&text */ $type-scale-small: ( h1: 2.686rem, h2: 2.148rem, h3: 1.719rem, h4: 1.375rem, p: 1.1rem ); $breakpoint-medium: 75em; $breakpoint-small: 45em; @mixin size($level) { font-size: map-get($type-scale-large, $level); @media (max-width: $breakpoint-medium) { font-size: map-get($type-scale-medium, $level); } @media (max-width: $breakpoint-small) { font-size: map-get($type-scale-small, $level); } } // Example .title { @include size(h1); }