Skip to content

Instantly share code, notes, and snippets.

@aaronice
Last active June 8, 2018 22:16
Show Gist options
  • Save aaronice/b6295c426293c7a465678c9e06690e09 to your computer and use it in GitHub Desktop.
Save aaronice/b6295c426293c7a465678c9e06690e09 to your computer and use it in GitHub Desktop.
CSS Typography

Web-safe Fonts and Font Family

Serif and Sans Serif Typefaces

  • Serif typefaces - small decorative lines;
  • Sans serif typefaces - no decorative lines;

Script and Decorative Typefaces

  • Script typefaces - hand-lettered look;
  • Decorative typefaces - distinct and ornamental

Monospace Typefaces

  • Each character uses the same amount of horizontal space

font-family

body {
  font-family: 'Helvetic Neue';
}

Font stack for fallback:

h2 {
	font-family: 'Helvetica Neue', Arial, san-serif;
}

Web Fonts and Google Fonts

internal font source (downloaded file)

@font-face {
	font-family: 'Museo Sans';
    src; url(museo-sans.ttf);
}

body {
	font-family: 'Museo Sans', Arial, sans-serif;
}

external font source (e.g. Google fonts)


<link href="https://fonts.googleapis.com/css?family=Indie+Flower" rel="stylesheet">


font-family: 'Indie Flower', cursive;

Font Size

Font Size: px, em, and rem

px

absolute value use whole number avoid decimal browser default: 16px

em

relative unit 1em = iherited font-size if no font-size declared, 1em = default = 16px

rem

similar to "em" relative unit, only to the root element (HTML), straightforward approach if no font-size declared, 1rem = 1em = default = 16px

Font Weight

font-weigth: 100, 200, 300, to 900 (thin to thick)

normal = 400; bold = 700;

Font Style

italic, norm, oblique

Line Height, Text Transform, Text Align

line-height

line-height should always > font-size

relative value: 1.5, 150%

text-transform

value: capitalize; uppercase, lowercase, none;

text-align

center

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment