CSS3 Fonts
CSS3 @font-face rule
With previous versions of CSS, web designers had to use fonts already installed on the user's computer.
Use CSS3, web designers can use any font he/she likes.
When you find the font file you want to use, simply include the font file in the website, and it will be automatically downloaded to the users who need it.
The font you choose is described in the new CSS3 version by the @font-face rule.
Your "own" fonts are defined in the CSS3 @font-face rule.
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| @font-face | 4.0 | 9.0 | 3.5 | 3.2 | 10.0 |
Internet Explorer 9+, Firefox, Chrome, Safari, and Opera support WOFF (Web Open Font Format) fonts.
Firefox, Chrome, Safari, and Opera support .ttf (True Type font) and .otf (OpenType) font types.
Chrome, Safari and Opera also support SVG fonts/folding.
Internet Explorer also supports EOT (Embedded OpenType) fonts.
Note: Internet Explorer 8 and earlier versions do not support the new @font-face rule.
Using the Font You Need
In the new @font-face rule, you must first define the name of the font (such as myFirstFont), and then point to the font file.
![]() |
**Tip:** Use lowercase letters for the font in the URL; uppercase letters will produce unexpected results in IE. |
|---|
To use the font for HTML elements, refer to the font name (myFirstFont) through the font-family property:
Example
<
style
@font
face
{font-family:
myFirstFont
;
src:
url
(
sansation
_
light
.
woff
)
;
}
div
{
font-family:
myFirstFont
;
}
style
Try it »
Using Bold Text
You must add another @font-face rule containing the bold text:
Example
@font
face
{
font-family:
myFirstFont
;
src:
url
(
sansation
_
bold
.
woff
)
;
font-weight:
bold
;
}
Try it »
The file "Sansation_Bold.ttf" is another font file containing the bold version of the Sansation font.
When the browser uses the font family "myFirstFont" for this text, it should be rendered in bold.
In this way you can have many @font-face rules for the same font.
CSS3 Font Descriptors
The following table lists all the font descriptors defined inside the @font-face rule:
| Descriptor | Value | Description |
|---|---|---|
| font-family | name | Required. Specifies the name of the font. |
| src | URL | Required. Defines the URL of the font file. |
| font-stretch |
|
- normal
- italic
- oblique
- normal
- bold
- 100
- 200
- 300
- 400
- 500
- 600
- 700
- 800
- 900
