HTML DOM fontStyle 屬性
定義和用法
fontStyle 屬性設(shè)置字體的風(fēng)格。
語(yǔ)法:
Object.style.fontStyle=normal|italic|oblique
可能的值
值 | 描述 |
---|---|
normal | 默認(rèn)。瀏覽器顯示一個(gè)標(biāo)準(zhǔn)的字體。 |
italic | 瀏覽器會(huì)顯示一個(gè)斜體的字體。 |
oblique | 瀏覽器會(huì)顯示一個(gè)傾斜的字體。 |
實(shí)例
本例向文本添加斜體樣式:
<html>
<head>
<script type="text/javascript">
function setFontStyle()
{
document.getElementById("p1").style.fontStyle="italic";
}
</script>
</head>
<body>
<p id="p1">This is an example paragraph.</p>
<input type="button" onclick="setFontStyle()"
value="Change font-style" />
</body>
</html>