HTML DOM font 屬性
定義和用法
font 屬性在一個(gè)聲明中設(shè)置所有字體屬性。
語法:
Object.style.font=value
可能的值
值 | 描述 |
---|---|
|
設(shè)置字體的屬性。 |
caption | 為控件定義字體(比如按鈕、下拉列表等)。 |
icon | 定義用于標(biāo)注圖標(biāo)的字體。 |
menu | 定義菜單中使用的字體。 |
message-box | 定義對(duì)話框中使用的字體。 |
small-caption | 定義用于標(biāo)注小型控件的字體。 |
status-bar | 定義在窗口狀態(tài)欄中使用的字體。 |
實(shí)例
本例改變文本的字體:
<html>
<head>
<script type="text/javascript">
function setFont()
{
document.getElementById("p1").style.font="italic bold 12px arial,serif";
}
</script>
</head>
<body>
<p id="p1">This is an example paragraph.</p>
<input type="button" onclick="setFont()" value="Change paragraph style" />
</body>
</html>