Properti visibilitas CSS
Contoh
Jadikan elemen <h2> terlihat dan disembunyikan:
h2.a {
visibility: visible;
}
h2.b {
visibility: hidden;
}
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Properti visibility
menentukan apakah suatu elemen terlihat atau tidak.
Tip: Elemen tersembunyi memakan ruang di halaman. Gunakan properti tampilan untuk menyembunyikan dan menghapus elemen dari tata letak dokumen!
Nilai bawaan: | terlihat |
---|---|
Diwarisi: | Ya |
Animasi: | Ya. Baca tentang animasi |
Versi: kapan: | CSS2 |
Sintaks JavaScript: | objek .style.visibility="tersembunyi" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
visibility | 1.0 | 4.0 | 1.0 | 1.0 | 4.0 |
Sintaks CSS
visibility: visible|hidden|collapse|initial|inherit;
Nilai properti
Value | Description | Play it |
---|---|---|
visible | Default value. The element is visible | |
hidden | The element is hidden (but still takes up space) | |
collapse | Only for table rows (<tr>), row groups (<tbody>), columns (<col>),
column groups (<colgroup>). This value removes a row or column,
but it does not affect the table layout. The space taken up by the row or column
will be available for other content. If collapse is used on other elements, it renders as "hidden" |
|
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
Contoh ini menunjukkan cara membuat elemen tabel runtuh:
tr.collapse {
visibility: collapse;
}
Halaman Terkait
Tutorial CSS: Tampilan dan visibilitas CSS
Referensi DOM HTML: properti visibilitas