Gaya fontStyle Property
Contoh
Setel font untuk elemen ke "miring":
document.getElementById("demo").style.fontStyle = "italic";
Definisi dan Penggunaan
Properti fontStyle menetapkan atau mengembalikan apakah gaya font normal, miring, atau miring.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
fontStyle | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti fontStyle:
object.style.fontStyle
Setel properti fontStyle:
object.style.fontStyle = "normal|italic|oblique|initial|inherit"
Nilai properti
Value | Description |
---|---|
normal | Font is normal. This is default |
italic | Font is in italic |
oblique | Font is in oblique |
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 gaya font teks dalam elemen |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Demonstrasi nilai yang mungkin:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontStyle = listValue;
Contoh
Kembalikan gaya font suatu elemen:
alert(document.getElementById("demo").style.fontStyle);
Halaman Terkait
Tutorial CSS: Font CSS
Referensi CSS: properti gaya font
Referensi DOM HTML: properti font
Objek Gaya