HTML and CSS Reference
In-Depth Information
You can also specify font sizes using em , which, like percentage, is another
relative unit of measure. With em , you don't specify a percentage; instead,
you specify a scaling factor. Here's how you use em :
Don't mix thi s
up with the
<em> e lement!
This sa ys that the
font si ze shou ld be
scaled by 1.2.
font-size: 1.2em;
Say you use this measurement to specify the size of an
<h2> heading. Your <h2> headings will be 1.2 times the
font size of the parent element, which in this case is 1.2
times 14px, which is about 17px.
It's actually 16.8, but
most browser s will
round it up t o 17.
body {
font-size: 14px;
And here's the <h2>
specified by 1. 2em.
}
h1 {
body is 14px
H ere's the <h1> specif ied
by a percentage.
font-size: 150%;
}
h2 {
h1 is 21px
p is 14px
h2 is 17px
font-size: 1.2em;
}
Search WWH ::




Custom Search