Style Object fontFamily Property
Style Object
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
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 »
|
Style Object

The Altova MissionKit is an integrated suite of tools ideal for:
- XML development
- Web & Web services development
- Data mapping & integration
- Rendering & publishing XML & database data
- XBRL validation, taxonomy editing, transformation & rendering
The MissionKit for XML Developers includes XMLSpy® - the industry-leading XML editor; MapForce® - a
graphical data mapping, conversion, and integration tool; StyleVision® - a visual XSLT stylesheet designer;
DiffDog® - an XML-aware diff/merge tool; and 2 additional tools.
Try all 6 products free for 30 days!
Download a fully-functional free trial
|
|
|
|