HTML and CSS Reference
In-Depth Information
This font declaration sets the
font-style
,
font-size
,
line-height
, and
font-family
properties in one declaration. Because
font-variant
and
font-weight
are not
included, a side effect of using this declaration is that they are both re-set to normal.
Custom fonts
Selected fonts can be seen only if the font is installed on the device used to view the web
site. If a nonstandard font is needed, a
@font-face
rule can be used to load the font from
an online location.
@font-face {
font-family: MyFont;
src: url(myfont.ttf);
}
This rule creates a font named
MyFont
and provides a URL from which the browser
can download it. With this rule in place, the custom font can be used just like any
standard font.
p { font-family: "MyFont", arial, sans-serif; }
This use of the
@font-face
rule is supported in Chrome 5+, Firefox 3.5+, IE9+,
Safari 3.1+, and Opera 10+. If the browser does not support the custom font, it reverts to
the next standard font in the list.