Specifying Font Family

In style language, a typeface is referred to as a “font family.” You specify which typeface you want to use like this:

font-family: name-or-names;


font-family: Helvetica;
font-family: Arial, Helvetica;
font-family: "Times New Roman", Times;
font-family: 'Zapf Dingbats', Symbol;
font-family: serif;
font-family: sans-serif;
font-family: monospace;

If you specify more than one name, the browser looks for the fonts, one after the other, until it finds one that's in the list. If it doesn't find any of them, it just uses the browser's default font. The last three examples ask the browser to look for a generic font of the given type. Notice that you must use either single or double quote marks around a font name if it contains spaces!

<span style="font-family: sans-serif;">Generic sans-serif text</span><br />
<span style="font-family: serif;">Generic serif text</span><br />
<span style="font-family: monospace;">Generic monospace text</span><br />
<span style="font-family: 'Times New Roman';">Times New Roman text</span><br />

The last example uses single quotes around the font family name, because we've already used up double quotes for the HTML attribute. Here's the result:

Generic sans-serif text
Generic serif text
Generic monospace text
Times New Roman text

  Specifying Size  Index Specifying Background Color