Typography on the Web

(and keyframes)

Before we start, please download this starter code and open it in a text editor. As we go through these CSS topics, mess around with the code on your machine and test these things out.

font-family, font-size

With CSS, we can assign any font to any div we want. There are a few places to get fonts from:

  • Our own system fonts:
  • Imported font files (.ttf, .woff, .otf)
  • Cloud based services like Google Fonts or Adobe Fonts

We use the font-family attribute to specify the name of the font, and font-size to set the height, and therefore size, of the font.

HTML
CSS
Result

Here's some big monospace type!

Style, Weight

We can change the font's style with font-style and font-weight:

HTML
CSS
Result

I'm tilted and thin!

Size Line Height, Letter Spacing

HTML
CSS
Result

Hey, was geht, ich spreche kein Deutsch, aber ich dachte, es wäre lustig, zu Ihrer Unterhaltung einen langen Satz in einen Übersetzer zu schreiben.

Decoration

text-decoration lets us add an underline and other stuff:
HTML
CSS
Result

I have an underline!

Fun text effects

HTML
CSS
Result

I have a shadow

I have an outline / stroke!



Keyframes!!!!!!

Ok this is not exactly related to typography but its fun: css keyframes give us a way to create an animation, and give it a name. We can use that name to apply it in our CSS rules.

HTML
CSS
Result

Whoa cool

Weeee!!!

Hover over me please