Gaya fontWeight Property
Contoh
Setel bobot font untuk elemen ke "900":
document.getElementById("demo").style.fontWeight = "900";
Definisi dan Penggunaan
Properti fontWeight mengatur atau mengembalikan seberapa tebal atau tipis karakter dalam teks harus ditampilkan.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti fontWeight:
object.style.fontWeight
Setel properti fontWeight:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
Nilai properti
Value | Description |
---|---|
normal | Font is normal. This is default |
lighter | Font is lighter |
bold | Font is bold |
bolder | Font is bolder |
100 200 300 400 500 600 700 800 900 |
Defines from light to bold characters. 400 is the same as normal, and 700 is the same as bold |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Detail Teknis
Nilai Bawaan: | normal |
---|---|
Nilai Kembali: | Sebuah String, mewakili keberanian font |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Demonstrasi nilai yang mungkin:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
Contoh
Kembalikan berat font suatu elemen:
alert(document.getElementById("demo").style.fontWeight);
Halaman Terkait
Tutorial CSS: Font CSS
Referensi CSS: properti font-weight
Referensi DOM HTML: properti font
Objek Gaya