CSS:font-size
From MDC
[edit] Summary
The font-size property specifies the size of the font. The font size may, in turn, change the size of other things, since it is used to compute the value of em and ex length units.
- Initial value:
medium - Applies to: all elements
- Inherited: Yes
- Percentages: relative to parent element's font size
- Media:
visual - Computed value: absolute length
[edit] Syntax
font-size: xx-small | x-small | small | medium | large | x-large | xx-large
font-size: smaller | larger
font-size: <length> | <percentage> | inherit
[edit] Values
- xx-small, x-small, small, medium, large, x-large, xx-large
- A set of absolute size keywords based on the user's default font size (which is
medium). Similar to presentational HTML's<font size="1">through<font size="7">where the user's default font size is<font size="3">. - larger, smaller
- Larger or smaller than the parent element's font size, by roughly the ratio used to separate the absolute size keywords above.
- <length>
- A positive length.
- <percentage>
- A positive percentage of the parent element's font size.
It is best to avoid using values that are not relative to the user's default font size, such as <lengths> with units other than em or ex. However, if such values must be used, px are preferred over other units because their meaning does not vary depending on what the operating system thinks (generally incorrectly) the resolution of the monitor is.
[edit] Examples
/* Set paragraph text to be very large. */
p { font-size: xx-large }
/* Set h1 (level 1 heading) text to be 2.5 times the size
* of the text around it. */
h1 { font-size: 250% }
/* Sets text enclosed within span tag to be 16px */
span { font-size: 16px; }
[edit] Notes
em and ex units on the font-size property are relative to the parent element's font size (unlike all other properties, where they're relative to the font size on the element). This means em units and percentages do the same thing for font-size.
[edit] Specifications
[edit] Browser compatibility
[edit] See also
font,
font-family,
font-size,
font-size-adjust,
font-stretch,
font-style,
font-variant,
font-weight,
@font-face