@font-face

設定要內嵌在 HTML 文件中的字型。

語法

@font-face { sFontDescription }

可能的值

sFontDescription

指定下列值的字串:

font-family: font-familyName

font-family 屬性可用的任何值範圍。

src: url(sURL)

字型檔案的位置,其中的 sURL 是絕對或相對 URL。

備註

此規則沒有預設值。

此功能可讓您使用電腦上可能未提供的特定字型。URL 必須指向內嵌的 OpenType 檔案 (.eot 或 .ote 格式)。該檔案包含轉換成 TrueType 字型的壓縮字型資料。

範例

下列範例會指向位於其他網站的字型來源,以便將字型內嵌在 HTML 文件中:

<html>
<head><style>
   @font-face {
      font-family:comic;
      src:url(http://valid_url/some_font_file.eot);
   }
</style>
</head>
<body>
<p style="font-family:comic;font-size:18pt">
This paragraph uses the font-face rule defined
in the preceding style element.  The rule embeds 
an OpenType file for the Comic Sans font.
</p>
</body>
</html>

標準資訊

此規則是在階層式樣式表 (CSS) 層級 2 (CSS2) Ee371244.xtlink_newWindow(zh-tw,Expression.40).png (英文) 中定義。

另請參閱

概念

font-family