22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In addition to the font size names (xx-small,<br />

x-small, small, medium, large,<br />

x-large, or xx-large), you can also assign<br />

font sizes by using the following <strong>CSS</strong> units<br />

of measure: px (pixels), pt (points), or em (the<br />

m-height for the font in use, whatever it may be).<br />

Pixels depend on the size of an individual pixel<br />

on your user’s display and will vary too much<br />

from screen to screen to be truly useful. Points<br />

are very small units of measure and may require<br />

too much experimentation to get just right. That<br />

The result appears in Figure 11-2.<br />

Chapter 11: Getting Creative with Colors and Fonts<br />

Sizing text fonts with <strong>CSS</strong><br />

Figure 11-2: First-level headings are twice as big as the base<br />

font; font size for other text is relative.<br />

Line height<br />

The line height of a paragraph is the amount of space between each line<br />

within the paragraph.<br />

Line height is like line spacing in a word processor.<br />

probably explains why em is the most widely<br />

used unit in sizing fonts in <strong>CSS</strong> nowadays, and<br />

why this approach is considered a best practice<br />

for sizing fonts using stylesheets. Choosing<br />

em units won’t free you from experimentation,<br />

but it will make it quick and easy for you to size<br />

type relative to your underlying font. For more<br />

information on using these units, which take the<br />

form font-size: 2em; (to double font size)<br />

or font-size: 0.8em; (to reduce a font to<br />

80 percent of the base), see Chapter 9.<br />

179

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!