UK [fɔnt ˈfæmili] US [fɑnt ˈfæməli]

glyph system

javascript fontFamily attribute syntax

Function: Define the font family used for element text display.

Syntax: Object.style.fontFamily=font1,font2,....
Comments: If the font family name contains spaces, please Add quotation marks.

javascript fontFamily attribute example

<html>
<head>
    <meta charset="utf-8">
<script type="text/javascript">
function setFont()
{
document.getElementById("p1").style.fontFamily="arial,sans-serif";
}
</script>
</head>
<body>

<p id="p1">这是示例文字</p>

<input type="button" onclick="setFont()" value="Change font" />

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance