The @font-face CSS at-rule 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. The @font-face at-rule may be used not only at the top level of a CSS, but also inside any CSS conditional-group at-rule.

Experimental: 這是一個實驗中的功能


@font-face {
  [font-family: <family-name>;]?
  [src: [ <uri> [format(<string>#)]? | <font-face-name> ]#;]?
  [unicode-range: <urange>#;]?
  [font-variant: <font-variant>;]?
  [font-feature-settings: normal|<feature-tag-value>#;]?
  [font-stretch: <font-stretch>;]?
  [font-weight: <weight>];
  [font-style: <style>];


Specifies a font name that will be used as font face value for font properties.
URL for the remote font file location, or the name of a font on the user's computer in the form local("Font Name").
A font-variant (en-US) value.
A font-stretch (en-US) value.
A font weight value.
A font style value.

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.


這個範例指定一個可供下載的字型,並套用至 document 的整個 body。


  <title>Web Font Sample</title>
  <style type="text/css" media="screen, print">
    @font-face {
      font-family: "Bitstream Vera Serif Bold";
      src: url("https://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");

    body { font-family: "Bitstream Vera Serif Bold", serif }
  This is Bitstream Vera Serif Bold.

這個範例會套用使用者本地的 "Helvetica Neue Bold" 字型,只有當使用者未安裝該字型(兩種名稱都試過了),才會下載 "MgOpenModernaBold.ttf" 字型:

@font-face {
  font-family: MyHelvetica;
  src: local("Helvetica Neue Bold"),
  font-weight: bold;


  • In Gecko, web fonts are subject to the same domain restriction (font files must be on the same domain as the page using them), unless HTTP access controls are used to relax this restriction.
  • Note: Because there are no defined MIME types for TrueType, OpenType, and Web Open File Format (WOFF) fonts, the MIME type of the file specified is not considered.
  • When Gecko displays a page that uses web fonts, it initially displays text using the best CSS fallback font available on the user's computer while it waits for the web font to finish downloading.  As each web font finishes downloading, Gecko updates the text that uses that font.  This allows the user to read the text on the page more quickly.


規格文件 狀態 註解
WOFF File Format 1.0
The definition of 'WOFF font format' in that specification.
Recommendation 字型格式規格文件
CSS Fonts Module Level 3
The definition of '@font-face' in that specification.


We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

功能特色 Firefox (Gecko) Chrome Internet Explorer Opera Safari
基本支援 3.5 (1.9.1) 4.0 4.0 10.0 3.1
WOFF 3.5 (1.9.1) 6.0 9.0 11.10 5.1
SVG 字型 No support
Unimplemented (see bug 119490)
No support

yes (bug 443976)

9.0 (Yes) (Yes)
功能特色 Android Firefox 行動版 (Gecko) IE 行動版 Opera Mini Opera 行動版 Safari 行動版
基本支援 (Yes) 1.0 (1.9.1) ? No support 10.0 (Yes)
WOFF No support 5.0 (5.0) ? No support 11.0 No support
SVG 字型 No support No support
Unimplemented (see bug 119490)
? No support 10.0 (Yes)
unicode-range           (Yes)


  • Support of the Embedded OpenType font format is not included in the compatibility table because it is a proprietary feature. Prior to IE 9.0, IE supported only this format.
  • TrueType and OpenType are not included because they are superseded by WOFF.