Specifying a Font Size and Color

There are many ways to set the font size in HTML, but all the methods use one of two strategies: either specify an absolute size or specify a size in relation to the parent tag.

To specify an absolute size, you use a number followed by a unit of measurement. The most common unit of measurement for Web pages is px, which stands for pixels. (An average size for text is 10px.) Pixels are the native unit of measurement for computer monitor display modes. HTML also accepts inches (in), centimeters (cm), millimeters (mm), points (pt), and picas (pc), but those units are most appropriate when working with a page that is designed to be printed.

The size of a pixel depends on the display resolution of the monitor. For example, ...

Get HTML and XHTML Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.