CSS Web Fonts
CSS web fonts allow users to use fonts that are not installed on the computer.
Different web fonts formats:
- TrueType Fonts (TTF) : TrueType Fonts is developed by Apple and Microsoft in the late 1980s. It is the most common font format for both the Mac OS and Microsoft Windows operating systems.
- OpenType Fonts (OTF) : OpenType Fonts is a format for scalable computer fonts and developed by Microsoft.
- The Web Open Font Format (WOFF) : WOFF is a font format for use in web pages.
- SVG Fonts/Shapes : SVG allow SVG fonts within SVG documentation. You can also apply CSS to SVG documents using font face property.
- Embedded OpenType Fonts (EOT) : Embedded OpenType Fonts designed by Microsoft for use as embedded fonts on web pages.
Here is an example of using web fonts:
Example:
@font-face {
font-family: myFirstFont;
src: url(Sansation_Light.ttf);
}
* {
font-family: myFirstFont;
}
font-family: myFirstFont;
src: url(Sansation_Light.ttf);
}
* {
font-family: myFirstFont;
}
Run Example
The following list contains all the fonts description which can be used in the @font-face rule:
- font-family - Defines the name of the font.
- src - Defines the url of the font.
- font-stretch - Defines how the font should be stretched.
- font-style - Defines how the font should be styled.
- font-weight - Defines the boldness of the font.
Browser Support
Font format | Firefox | Chrome | IE | Opera | Safari |
---|---|---|---|---|---|
TTF | 3.5 | 4.0 | 9.0 | 10.0 | 3.1 |
OTF | 3.5 | 4.0 | 9.0 | 10.0 | 3.1 |
WOFF | 3.6 | 5.0 | 9.0 | 11.1 | 5.1 |
SVG | Not supported | 4.0 | Not supported | 9.0 | 3.2 |
EOT | Not supported | Not supported | 6.0 | Not supported | Not supported |