English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
font-The size CSS property is used to set the font size of the element's text content.
The following table provides usage instructions and version history of this attribute, as well as its syntax in JavaScript scripts.
Default value: | medium |
---|---|
Applies to: | All elements |
Inheritance: | Yes |
Animatable: | Yes.Please refer to Animation properties. |
Version: | CSS 1,2,3 |
JavaScript syntax: | JavaScript syntax: object.style.fontSize="medium" |
The syntax of this attribute is as follows:
font-size: xx-small | x-small | small | medium | large | x-large | xx-large | smaller | larger | length | percentage | initial | inherit
The following example demonstrates how to use font-size attribute.
body { font-size: 14px; } h1 { font-size: 2em; }Test see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
xx-small | A set of absolute size keywords. These keywords are scaled to the text font size based on the user's browser font setting preferences and the browser's internal font scaling algorithm. The font-The median value of the size attribute (16px) matches the default font size of the user's browser. |
x-small | |
small | |
medium | |
large | |
x-large | |
xx-large | |
smaller | Less than or greater than or greater than the font size of the parent element, used to separate the proportion of the above absolute size keywords. For example, if the font size of the parent element is medium, the value of larger will make the font size of the current element large. |
larger | |
length | Use length units such as px, pt, cm, em, etc., and negative values are not allowed. |
percentage | Set the font size to a percentage of the font size of the parent element. Negative values are not allowed. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts the font of its parent element font-size attribute values. |
Note:font-The default value of the size attribute in all modern browsers (such as Firefox, Chrome, IE, Safari, Opera, etc.) is medium (16px).
font-Browser compatibility of the size attribute, the numbers in the following table represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS font,CSS text.
Related properties and rules:line-height,font,font-family,font-style,font-variant,font-weight,@font-face.