目录

CSS font-size 属性


示例

设置不同元素的字体大小:

div.a {
  font-size: 15px;
}

div.b {
  font-size: large;
}

div.c {
  font-size: 150%;
}
亲自试一试 »

定义和用法

这个font-size属性设置字体的大小。

展示演示❯

默认值: 中等的
遗传: 是的
可动画: 是的。阅读可动画的尝试一下
版本: CSS1
JavaScript 语法: 对象.style.fontSize="14px"尝试一下

浏览器支持

表中的数字指定完全支持该属性的第一个浏览器版本。

Property
font-size 1.0 5.5 1.0 1.0 7.0


CSS 语法

font-size:medium|xx-small|x-small|small|large|x-large|xx-large|smaller|larger| length|initial|inherit;

属性值

Value Description Demo
medium Sets the font-size to a medium size. This is default Demo ❯
xx-small Sets the font-size to an xx-small size Demo ❯
x-small Sets the font-size to an extra small size Demo ❯
small Sets the font-size to a small size Demo ❯
large Sets the font-size to a large size Demo ❯
x-large Sets the font-size to an extra large size Demo ❯
xx-large Sets the font-size to an xx-large size Demo ❯
smaller Sets the font-size to a smaller size than the parent element Demo ❯
larger Sets the font-size to a larger size than the parent element Demo ❯
length Sets the font-size to a fixed size in px, cm, etc. Read about length units Demo ❯
% Sets the font-size to a percent of  the parent element's font size Demo ❯
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

相关页面

CSS教程:CSS 字体

CSS 参考:字体属性

HTML DOM 参考:字体大小属性