CUSTOMIZE AN ELEMENT’S FONT

No longer are you limited to so-called web safe fonts, the short list of fonts built into browsers and defined in HTML 4.01. CSS3 adds support for custom fonts. You can actually import your own TrueType (TTF), OpenType (OTF), and Embedded OpenType (EOT) font files into your web page:

@font-face {
  font-family: MyFont;
  src: url(myfont.ttf), url(myfont.eot);
}
selector { font-family: MyFont; }

@font-face uses a selector-like syntax that you can use and reuse, once for each new custom font. The font-family property assigns a proper name to the font and is used later when assigning the font with a CSS rule.

The files referenced by the src property must be stored on your web server. They will be downloaded by the web ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.