Properti perbatasan gaya
Contoh
Tambahkan batas ke elemen <div>:
document.getElementById("myDiv").style.border = "thick solid #0000FF";
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Properti perbatasan menyetel atau mengembalikan hingga tiga properti perbatasan terpisah, dalam bentuk singkatan.
Dengan properti ini, Anda dapat mengatur/mengembalikan satu atau beberapa hal berikut (dalam urutan apa pun):
- lebar batas
- gaya perbatasan
- perbatasan-warna
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
border | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Sintaksis
Kembalikan properti perbatasan:
object.style.border
Setel properti perbatasan:
object.style.border = "width style color|initial|inherit"
Nilai properti
Parameter | Description |
---|---|
width | Sets the width of the borders |
style | Sets the style of the borders |
color | Sets the color of the borders |
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: | tidak ditentukan |
---|---|
Nilai Kembali: | Sebuah String, mewakili lebar perbatasan, gaya dan/atau warna elemen |
Versi CSS | CSS1 |
Lebih Banyak Contoh
Contoh
Ubah lebar, gaya, dan warna batas elemen <div>:
document.getElementById("myDiv").style.border = "thin dotted red";
Contoh
Kembalikan nilai properti perbatasan dari elemen <div>:
alert(document.getElementById("myDiv").style.border);
Halaman Terkait
Tutorial CSS: Perbatasan CSS
Referensi CSS: properti perbatasan