Properti warna CSS
Contoh
Atur warna teks untuk elemen yang berbeda:
body
{
color: red;
}
h1
{
color: #00ff00;
}
p.ex
{
color: rgb(0,0,255);
}
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Properti color
menentukan warna teks.
Tips: Gunakan warna latar belakang yang dipadukan dengan warna teks yang membuat teks mudah dibaca.
Nilai bawaan: | tidak ditentukan |
---|---|
Diwarisi: | Ya |
Animasi: | Ya. Baca tentang animasi |
Versi: kapan: | CSS1 |
Sintaks JavaScript: | objek .style.color="#0000FF" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
color | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
Sintaks CSS
color: color|initial|inherit;
Nilai properti
Value | Description | Play it |
---|---|---|
color | Specifies the text color. Look at CSS Color Values for a complete list of possible color values. | |
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 warna teks dengan nilai HEX:
body {color: #92a8d1;}
Contoh
Atur warna teks dengan nilai RGB:
body {color: rgb(201, 76, 76);}
Contoh
Atur warna teks dengan nilai RGBA:
body {color: rgba(201, 76, 76, 0.6);}
Contoh
Atur warna teks dengan nilai HSL:
body {color: hsl(89, 43%, 51%);}
Contoh
Atur warna teks dengan nilai HSLA:
body {color: hsla(89, 43%, 51%, 0.6);}
Halaman Terkait
Tutorial CSS: Teks CSS
Referensi DOM HTML: properti warna