Properti ketinggian garis CSS
Contoh
Atur tinggi garis untuk elemen <div> yang berbeda:
div.a {
line-height: normal;
}
div.b {
line-height: 1.6;
}
div.c {
line-height:
80%;
}
div.d {
line-height: 200%;
}
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Properti line-height
menentukan ketinggian garis.
Catatan: Nilai negatif tidak diperbolehkan.
Nilai bawaan: | normal |
---|---|
Diwarisi: | Ya |
Animasi: | Ya. Baca tentang animasi |
Versi: kapan: | CSS1 |
Sintaks JavaScript: | objek .style.lineHeight="30px" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
line-height | 1.0 | 4.0 | 1.0 | 1.0 | 7.0 |
Sintaks CSS
line-height: normal|number|length|initial|inherit;
Nilai properti
Value | Description | Play it |
---|---|---|
normal | A normal line height. This is default | |
number | A number that will be multiplied with the current font-size to set the line height | |
length | A fixed line height in px, pt, cm, etc. | |
% | A line height in percent of the current font size | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Lebih Banyak Contoh
Contoh
Atur tinggi garis dalam piksel dan sentimeter untuk elemen <div> yang berbeda:
div.a {
line-height: 10px;
}
div.b {
line-height: 30px;
}
div.c {
line-height:
0.5cm;
}
div.d {
line-height: 1cm;
}
Contoh
Tetapkan tinggi garis sebagai angka untuk elemen <div> yang berbeda:
div.a {
line-height: 0.5;
}
div.b {
line-height: 1.6;
}
div.c {
line-height: 2;
}
Halaman Terkait
Tutorial CSS: Teks CSS
Referensi DOM HTML: properti lineHeight