font-family
Description
font-family
defines a font family.
A specific font family is dependent on availability on a user's machine.
Item | Value |
---|---|
Initial value | |
Inherited | Yes. |
Version | CSS1 |
JavaScript syntax | object.style.fontFamily="arial,sans-serif" |
Applies to | All elements. |
Syntax and Property Values
font-family: font 1 [, font 2, ... font N]
The property values are listed in the following table.
Value | Description |
---|---|
family-name | A list of font family names and/or generic family names in prioritized order |
inherit | Inherit the font family from the parent element |
Example
The following code shows how to use different font names to set
font-family
.
p {font-family: Helvetica, Arial, sans-serif;}
li {font-family: Times, TimesNR, "New Century Schoolbook", serif;}
pre {font-family: Courier, Monaco, monospace;}
<!DOCTYPE HTML>
<html>
<head>
<style>
p#serif {<!--from w w w . j av a 2 s . c o m-->
font-family: serif;
}
</style>
</head>
<body>
<p id='serif'>
This is serif.
</p>
</body>
</html>
The code above generates the following result.