HTML DOM fontFamily Property
Complete Style Object Reference
Definition and Usage
The fontFamily property specifies a list of font-family names and/or
generic-family names for an element.
The browser will use the first value it
recognizes.
There are two types of font-family values:
- font-family: The name of a font-family, like "verdana" or "arial"
- generic-family: The name of a generic font-family, like "serif"
or
"sans-serif"
Syntax
Object.style.fontFamily=font1,font2,....
|
Possible Values
Value |
Description |
font1, font2,.... |
A comma-separated list of font-family names and/or generic-family
names for an element |
Tips and Notes
Tip: Always specify a
generic-family name as the last alternative.
Note: If a font-family name contains white-space, it should be quoted.
Example
The following example changes the font-family of a text:
<html>
<head>
<script type="text/javascript">
function setFont()
{
document.getElementById("p1").style.fontFamily="arial,sans-serif";
}
</script>
</head>
<body>
<p id="p1">This is an example paragraph.</p>
<input type="button" onclick="setFont()" value="Change font" />
</body>
</html>
|
Try-It-Yourself Demos
fontFamily - Change the font-family of a text
Complete Style Object Reference
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|