HTML and CSS Reference
In-Depth Information The font-size property
The font-size property lets you prescribe absolute or relative length val-
ues, percentages, and keywords to define the font size. For example:
p {font-size: 12pt}
p {font-size: 120%}
p {font-size: +2pt}
p {font-size: medium}
p {font-size: larger}
The first rule is probably the most used, because it is the most familiar:
it sets the font size for text enclosed in your document's paragraph(s)
to a specific number of points (12 in this example). The second example
rule sets the font size to be 20 percent larger than the parent element's
font size. The third increases the font's normal size by 2 points.
The fourth example selects a predefined font size set by the browser,
identified by the medium keyword. Valid absolute-size keywords are xx-
small, x-small, small, medium, large, x-large , and xx-large ; these usu-
ally correspond to the seven font sizes used with the size attribute of
the <font> tag.
The last font-size rule selects the next size larger than the font asso-
ciated with the parent element. Thus, if the size were normally medium ,
it would be changed to large . You can also specify smaller , with the ex-
pected results.
None of the current browsers handles incremented or decremented font
sizes correctly. Rather, they ignore the decrement sign and size alto-
gether, and misinterpret the incremented size value as an absolute size.
For instance, in the middle example in this section, the font size would
end up as 2 points, not 2 points larger than the normal size.
Search WWH ::

Custom Search