« CSS « CSS Reference
@font-face allows authors to specify online fonts to display text on their web pages. By allowing authors to provide their own fonts, @font-face eliminates the need to depend on the limited number of fonts users have installed on their computers.
@font-face {
font-family: <a-remote-font-name>;
src: <source> [,<source>]*;
[font-weight: <weight>];
[font-style: <style>];
}
local("Font Name").You can specify a font on the user's local computer by name using the local() syntax. If that font isn't found, other sources will be tried until one is found.
This example simply specifies a downloadable font to use, applying it to the entire body of the document.
<html>
<head>
<title>Web Font Sample</title>
<style type="text/css" media="screen, print">
@font-face {
font-family: "Bitstream Vera Serif Bold";
src: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");
}
body { font-family: "Bitstream Vera Serif Bold", serif }
</style>
</head>
<body>
This is Bitstream Vera Serif Bold.
</body>
</html>
In this example, the user's local copy of "Helvetica Neue Bold" is used; if the user doesn't have that font installed (two different names are tried), then the downloadable font named "MgOpenModernaBold.ttf" is used instead:
@font-face {
font-family: MyHelvetica;
src: local("Helvetica Neue Bold"),
local("HelveticaNeue-Bold"),
url(MgOpenModernaBold.ttf);
font-weight: bold;
}
| Browser | Lowest version | Support of |
|---|---|---|
| Internet Explorer | 4.0 | Embedded OpenType fonts only |
| Firefox (Gecko) | 3.5 (1.9.1) | TrueType and OpenType fonts only |
| 3.6 (1.9.2) | Web Open Font Format (WOFF) | |
| Opera | 10.0 | TrueType and OpenType fonts only |
| Safari (WebKit) | 3.1 (525) | TrueType and OpenType fonts only |
See also MSDN Microsoft library @font-face.
Page last modified 15:34, 15 Jun 2010 by Sheppy
| File | Size | Date | Attached by | |||
|---|---|---|---|---|---|---|
| VeraSeBd.ttf No description | 57.36 kB | 20:44, 13 Oct 2008 | Sheppy | Actions | ||
| webfont-sample.html No description | 394 bytes | 15:58, 18 May 2009 | Sheppy | Actions | ||