Mengatur Jenis Huruf HTML Menggunakan fontFamily Style DOM
![]() |
Properti fontFamily Style DOM |
Sintak:
- digunakan untuk mengembalikan nilai properti fontFamily: object.style.fontFamily
- digunakan untuk mengatur nilai properti: object.style.fontFamily = "font1, font2, dan seterusnya|initial|inherit"
Property Value:
- font1, font2: daftar nama font-family dan nama generic-family yang dipisahkan oleh tanda koma.
- initial: digunakan untuk mengatur properti ke nilai default-nya.
- inherit: digunakan untuk menerima nilai turunan dari elemen parent.
Return Value: berfungsi untuk mengembalikan nilai angka dari mnama font-family dan nama generic family names.
<!DOCTYPE html>
<html>
<head>
<title>
Properti Style fontFamily DOM
</title>
</head>
<body>
<center>
<p
style="color: green;
width: 100%;
font-size: 30px;
font-weight: bold;"
id="Bon1">
Blog Elfan
</p>
<h2>
Properti Style fontFamily DOM
</h2>
<br>
<button
type="button"
onclick="myBons()">
Click to change
</button>
<script>
function myBons()
{
// Mengatur font-family
// 'impact'.
document.getElementById(
"Bon1").style.fontFamily = "Impact";
}
</script>
</center>
</body>
</html>
Blog Elfan
Properti Style fontFamily DOM
Contoh: nama font-family "sans-serif".
<!DOCTYPE html>
<html>
<head>
<title>
Properti Style fontFamily DOM
</title>
</head>
<body>
<center>
<p
style="color: green;
width: 100%;
font-size: 30px;
font-weight: bold;" id="Bon21">
Blog Elfan
</p>
<h2>
Properti Style fontFamily DOM
</h2>
<br>
<button
type="button"
onclick="myBon2s()">
Click to change
</button>
<script>
function myBon2s()
{
// Pengaturan font-family
// 'sans-serif'.
document.getElementById(
"Bon21").style.fontFamily = "sans-serif";
}
</script>
</center>
</body>
</html>
Blog Elfan
Properti Style fontFamily DOM
Contoh: nama font-family "Comic Sans MS, cursive, sans-serif".
<!DOCTYPE html>
<html>
<head>
<title>
Properti Style fontFamily DOM
</title>
</head>
<body>
<center>
<p
style="color: green;
width: 100%;
font-size: 30px;
font-weight: bold;" id="Gon1">
Blog Elfan
</p>
<h2>
Properti Style fontFamily DOM
</h2>
<br>
<button
type="button"
onclick="myGons()">
Click to change
</button>
<script>
function myGons()
{
// Pengaturan font-family
// 'Comic Sans MS, cursive,
// dan sans-serif'
document.getElementById(
"Gon1").style.fontFamily =
'Comic Sans MS, cursive, sans-serif';
}
</script>
</center>
</body>
</html>
Blog Elfan
Properti Style fontFamily DOM
- 4 Value Properti fontSizeAdjust Style DOM pada HTML [klik]
- 5 Value Properti Height Style DOM pada HTML [klik]
- 4 Value Properti Isolation Style DOM pada HTML [klik]
- 8 Value Properti justifyContent Style DOM pada HTML [klik]
- 5 Value Properti Left Style DOM pada HTML [klik]
- 4 Value Properti letterSpacing Style DOM pada HTML [klik]
- 6 Value Properti lineHeight Style DOM pada HTML [klik]
Jenis browser apa saja yang dapat digunakan untuk mengaktifkan properti fontFamily Style DOM pada HTML?
BalasHapusBerikut adalah beberapa jenis browser yang dapat digunakan untuk mengaktifkan properti fontFamily Style DOM pada HTML:
Hapus1. Google Chrome
2. Internet Explorer
3. Mozilla firefox
4. Opera
5. Safari
Apa yang dimaksud dengan font-family style dom pada HTML?
BalasHapusProperti fontFamily Style DOM pada HTML merupakan properti yang digunakan untuk mengatur atau mengembalikan daftar nama font-family dan atau nama generic-family untuk teks dalam sebuah elemen.
HapusProperti fontFamily style dom pada HTML merupakan properti yang digunakan untuk mengontrol font mana yang yang akan digunakan dalam dokumen HTML.
Hapus