Properti ruang putih gaya
Contoh
Tentukan bahwa teks dalam elemen <div> tidak akan pernah terbungkus:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definisi dan Penggunaan
Properti whiteSpace mengatur atau mengembalikan cara menangani tab, jeda baris, dan spasi putih dalam teks.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti whiteSpace:
object.style.whiteSpace
Setel properti whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Nilai properti
Value | Description |
---|---|
normal | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default |
nowrap | Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered |
pre | Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML |
pre-line | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks |
pre-wrap | Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks |
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 bagaimana ruang putih di dalam elemen ditangani |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Kembalikan properti whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Halaman Terkait
Tutorial CSS: Teks CSS
Referensi CSS: properti spasi putih
Objek Gaya