HTML DOM fontWeight 屬性
定義和用法
fontWeight 屬性設(shè)置字符的粗細(xì)。
語法:
Object.style.fontWeight=value
可能的值
值 | 描述 |
---|---|
normal | 默認(rèn)。定義標(biāo)準(zhǔn)的字符。 |
bold | 定義粗體字符。 |
bolder | 定義更粗的字符。 |
lighter | 定義更細(xì)的字符。 |
|
定義由粗到細(xì)的字符。400 等同于 normal,而 700 等同于 bold。 |
實(shí)例
本例把第一段設(shè)置為粗體:
<html>
<head>
<script type="text/javascript">
function setFontWeight()
{
document.getElementById("p1").style.fontWeight="900";
}
</script>
</head>
<body>
<p id="p1">This is an example paragraph.</p>
<p>This is another example paragraph.</p>
<input type="button" onclick="setFontWeight()"
value="Display bold text" />
</body>
</html>