# @font-face
**版本:CSS3**
继承性:无
### 语法:
**@font-face** :{*属性: 取值;*}
### 取值:
font-family:设置文本的字体名称。 font-style:设置文本样式。font-variant:设置文本是否大小写。 font-weight:设置文本的粗细。 font-stretch:设置文本是否横向的拉伸变形。font-size:设置文本字体大小。*src*:设置自定义字体的相对路径或者绝对路径,注意,此属性只能在@font-face规则里使用。
### 说明:
@font-face 能够加载服务器端的字体文件,让客户端显示客户端所没有安装的字体。【微软的IE 5已经是开始支持这个属性,但是只支持微软自有的.eot (Embedded Open Type) 格式,而其他浏览器直到现在都没有支持这一字体格式。然而,从Safari 3.1开始,网页重构工程师已经可以设置.ttf(TrueType)和.otf(OpenType)两种字体做为自定义字体了。】
### 兼容性:
### .eot格式
<table><thead><tr><th class="type">类型</th> <th class="type_ie"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d41490.png" alt="IE" />Internet Explorer</th> <th class="type_firefox"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d48c83.png" alt="Firefox" />Firefox</th> <th class="type_chrome"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d511b8.png" alt="Chrome" />Chrome</th> <th class="type_opera"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d59c10.png" alt="Opera" />Opera</th> <th class="type_safari"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d6241b.png" alt="Safari" />Safari</th> </tr></thead><tbody><tr><td rowspan="4" class="version">版本</td> <td class="support yes"><span>(√)</span>IE6</td> <td class="support no"><span>(×)</span>Firefox 2.0</td> <td class="support no"><span>(×)</span>Chrome 1.0.x</td> <td class="support no"><span>(×)</span>Opera 9.63</td> <td class="support no"><span>(×)</span>Safari 3.1</td> </tr><tr><td class="support yes"><span>(√)</span>IE7</td> <td class="support no"><span>(×)</span>Firefox 3.0</td> <td class="support no"><span>(×)</span>Chrome 2.0.x</td> <td></td> <td class="support no"><span>(×)</span>Safari 4</td> </tr><tr><td class="support yes"><span>(√)</span>IE8</td> <td></td> <td></td> <td></td> <td></td> </tr><tr><td></td> <td></td> <td></td> <td></td> <td></td> </tr></tbody></table>
### .ttf格式
<table><thead><tr><th class="type">类型</th> <th class="type_ie"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d69861.png" alt="IE" />Internet Explorer</th> <th class="type_firefox"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d71d5b.png" alt="Firefox" />Firefox</th> <th class="type_chrome"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d79858.png" alt="Chrome" />Chrome</th> <th class="type_opera"><img src="https://box.kancloud.cn/2015-09-02_55e5d38d82a29.png" alt="Opera" />Opera</th> <th class="type_safari"><img src="https://box.kancloud.cn/2015-09-02_55e5d38dbed1a.png" alt="Safari" />Safari</th> </tr></thead><tbody><tr><td rowspan="4" class="version">版本</td> <td class="support no"><span>(×)</span>IE6</td> <td class="support no"><span>(×)</span>Firefox 2.0</td> <td class="support no"><span>(×)</span>Chrome 1.0.x</td> <td class="support no"><span>(×)</span>Opera 9.63</td> <td class="support yes"><span>(√)</span>Safari 3.2.1</td> </tr><tr><td class="support no"><span>(×)</span>IE7</td> <td class="support no"><span>(×)</span>Firefox 3.0</td> <td class="support no"><span>(×)</span>Chrome 2.0.x</td> <td class="support yes"><span>(√)</span>Opera 10</td> <td class="support yes"><span>(√)</span>Safari 4</td> </tr><tr><td class="support no"><span>(×)</span>IE8</td> <td class="support yes"><span>(√)</span>Firefox 3.5</td> <td></td> <td></td> <td></td> </tr><tr><td></td> <td></td> <td></td> <td></td> <td></td> </tr></tbody></table>
### EOT字体示例(本示例源自微软[Festival of Ornament](http://www.microsoft.com/typography/web/embedding/demos/3/demo3.htm)):
![](https://box.kancloud.cn/2015-09-02_55e5d38dc7a3a.png)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Festival of Ornament</title><base href="http://www.microsoft.com/typography/web/embedding/demos/3/" /><style type="text/css">@font-face { font-family: BorderWeb; src:url(BORDERW0.eot);}@font-face { font-family: Runic; src:url(RUNICMT0.eot);}@font-face { font-family: Kingston; src:url(KINGSTON.eot);}*{background:#FFF}.king { FONT-SIZE: 45pt; FONT-FAMILY: "Kingston" }.border { FONT-SIZE: 35px; COLOR: black; FONT-FAMILY: "BorderWeb" }.border2 { FONT-SIZE: 35px; COLOR:black; FONT-FAMILY: "BorderWeb" }.event { FONT-SIZE: 110px; COLOR: black; FONT-FAMILY: "Runic" }.locale { FONT-SIZE: 40px; COLOR: black; FONT-FAMILY: "Runic" }.bullet { FONT-SIZE: 50px; COLOR: black; FONT-FAMILY: "BorderWeb" }.corner { FONT-SIZE: 70px; COLOR: black; FONT-FAMILY: "BorderWeb" }a { FONT-SIZE: 10px; COLOR: black; FONT-FAMILY: Verdana; TEXT-DECORATION: none }</style></head><body><table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td valign="bottom" align="middle" bgcolor="olive" colspan="2" rowspan="2"><span class="corner">6</span></td> <td valign="bottom" align="middle" bgcolor="black" height="35"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="olive" colspan="2" rowspan="2"><span class="corner">5</span></td> </tr> <tr> <td valign="bottom" align="middle" bgcolor="khaki" height="35"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> </tr> <tr> <td align="middle" bgcolor="black" height="70"><span class="border2">8<br />7</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">A</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">a</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">B</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">b</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">C</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">c</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td align="middle" bgcolor="black"><span class="border2">8<br />7</span></td> </tr> <tr> <td align="middle" bgcolor="black" height="70"><span class="border2">8<br />7</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">d</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">D</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">e</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">E</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">f</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">F</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td align="middle" bgcolor="black"><span class="border2">8<br />7</span></td> </tr> <tr> <td align="middle" bgcolor="black" height="70"><span class="border2">8<br />7</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">G</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">g</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">H</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">h</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">I</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">i</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td align="middle" bgcolor="black"><span class="border2">8<br />7</span></td> </tr> <tr> <td align="middle" bgcolor="black" height="70"><span class="border2">8<br />7</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">j</span></td> <td align="middle" bgcolor="khaki"><span class="king">J</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">k</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">K</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">l</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">L</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td align="middle" bgcolor="black"><span class="border2">8<br />7</span></td> </tr> <tr> <td align="middle" bgcolor="black" height="70"><span class="border2">8<br />7</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">M</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">m</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">N</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">n</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">O</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">o</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td align="middle" bgcolor="black"><span class="border2">8<br />7</span></td> </tr> <tr> <td align="middle" bgcolor="black" height="70"><span class="border2">8<br />7</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">p</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">P</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">q</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">Q</span></td> <td valign="bottom" align="middle" bgcolor="olive"><span class="king">r</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="king">R</span></td> <td align="middle" bgcolor="khaki"><span class="border">7<br />8</span></td> <td align="middle" bgcolor="black"><span class="border2">8<br />7</span></td> </tr> <tr> <td valign="bottom" align="middle" bgcolor="olive" colspan="2" rowspan="2"><span class="corner">5</span></td> <td valign="bottom" align="middle" bgcolor="khaki" height="35"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="khaki"><span class="border">78</span></td> <td valign="bottom" align="middle" bgcolor="olive" colspan="2" rowspan="2"><span class="corner">6</span></td> </tr> <tr> <td valign="bottom" align="middle" bgcolor="black" height="35"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> <td valign="bottom" align="middle" bgcolor="black"><span class="border2">87</span></td> </tr> <tr> <td height="15"></td> </tr> <tr> <td valign="top" colspan="10"> <div class="event" align="center">FESTIVAL OF ORNAMENT</div> <div class="locale" align="center">UNIVERSITY OF CARDIFF <span class="bullet">4</span> JUNE 16 – 28</div> </td> </tr> </tbody></table></body></html>
复制代码
Copyright © 2009 [Tencent ISD webteam](http://webteam.tencent.com/). All Rights Reserved
### 快速跳转
- [语法](# "跳转到“语法”")
- [取值](# "跳转到“取值”")
- [说明](# "跳转到“说明”")
- [兼容性](# "跳转到“兼容性”")
- [示例](# "跳转到“示例”")
- CSS3 Properties
- 边框(Border)
- Border-color
- Border-image
- Border-radius
- box-shadow
- 背景(Background)
- background-origin
- background-clip
- Background-size
- Multiple backgrounds
- 颜色(Color)
- HSL colors
- HSLA colors
- opacity
- RGBA colors
- 文本(Text effects)
- text-shadow
- text-overflow
- word-wrap
- 用户界面(User-interface)
- box-sizing
- resize
- outline
- outline-width
- outline-style
- outline-offset
- outline-color
- nav-index
- nav-up
- nav-right
- nav-down
- nav-left
- 基础盒模型(Basic box model)
- overflow
- overflow-x
- overflow-y
- 内容(Generated Content)
- content
- 其它模块(Other modules)
- media queries
- Speech
- columns
- column-width
- column-span
- column-rule
- column-rule-color
- column-rule-width
- column-rule-style
- column-gap
- column-fill
- column-count
- column-break-before
- column-break-after
- @font-face
- 选择器(selectors)
- 子串匹配的属性选择符 E[att^="val"]
- 子串匹配的属性选择符 E[att$="val"]
- 子串匹配的属性选择符 E[att*="val"]
- 结构性伪类 E:root
- 结构性伪类 E:nth-child(n)
- 结构性伪类 E:nth-last-child(n)
- 结构性伪类 E:nth-of-type(n)
- 结构性伪类 E:nth-last-of-type(n)
- 结构性伪类 E:last-child
- 结构性伪类 E:first-of-type
- 结构性伪类 E:only-child
- 结构性伪类 E:only-of-type
- 结构性伪类 E:empty
- UI元素状态伪类 E:checked
- UI元素状态伪类 E:enabled
- UI元素状态伪类 E:disabled
- UI元素状态伪类 E::selection
- 否定伪类 E:not(s)
- 目标伪类 E:target
- 通用兄弟元素选择器 E ~ F