Teks Gaya Sejajarkan Properti
Contoh
Rata tengah teks dalam elemen:
document.getElementById("demo").style.textAlign = "center";
Definisi dan Penggunaan
Properti textAlign mengatur atau mengembalikan perataan horizontal teks dalam elemen level blok.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
textAlign | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti textAlign:
object.style.textAlign
Setel properti textAlign:
object.style.textAlign = "left|right|center|justify|initial|inherit"
Nilai properti
Value | Description |
---|---|
left | Aligns the text to the left. This is default |
right | Aligns the text to the right |
center | Centers the text |
justify | The text is justified |
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: | kiri |
---|---|
Nilai Kembali: | Sebuah String, mewakili perataan horizontal teks di dalam elemen |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Mengembalikan perataan teks elemen:
alert(document.getElementById("demo").style.textAlign);
Halaman Terkait
Tutorial CSS: Teks CSS
Referensi CSS: properti perataan teks
Objek Gaya