|
The font-family property sets the font that you want to use for text. You can specify a single font, a list of alternative fonts separated by commas or a generic font family. The list is called a font set. Here are some examples: body {font-family: Arial;} body {font-family: Arial, Verdana;} It is a good idea to give alternatives. If the browser can't use the first font, it tries the second and so on until it finds one that works or runs out of fonts and uses the browser's default font. In our example, the browser uses Verdana on systems that don't have Arial. Most machines have Arial, Courier and Times New Roman (they come with Windows) and Internet Explorer installs Verdana and Comic Sans MS. You might also need to specify more than one font if you have mathematical symbols or foreign language characters on your page: body {font-family: Arial, symbol;} You text will appear in Arial and the symbols use the Symbol font. It is also a good idea to specify a generic family name in case the system doesn't have any of your fonts: body {font-family: Arial, Verdana, sans-serif;} The browser then picks a similar font that it does have. The generic family names are:
Most browsers do quite a good job with serif, sans-serif and monospace fonts but not such good one with cursive or fantasy fonts. I don’t think Netscape supports either cursive or fantasy fonts. If you use a font name that consists of more than one word, put quotation marks round the name: {font-family: "Courier New;"} {font-family: "Times New Roman";} You can use single or double quotation marks. If you group properties, make sure font-family is the last one in the list. |
More information font-family |