Stil rengi Özellik
Örnek
Farklı öğeler için metin rengini ayarlayın:
document.getElementById("myH2").style.color = "#ff0000";
document.getElementById("myP").style.color = "magenta";
document.getElementById("myP2").style.color = "blue";
document.getElementById("myDiv").style.color = "lightblue";
Tanım ve Kullanım
color özelliği, metnin rengini ayarlar veya döndürür.
Tarayıcı Desteği
Property | |||||
---|---|---|---|---|---|
color | Yes | Yes | Yes | Yes | Yes |
Sözdizimi
color özelliğini döndürün:
object.style.color
color özelliğini ayarlayın:
object.style.color = "color|initial|inherit"
Mülk değerleri
Value | Description |
---|---|
color | Specifies the color of the text. 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 |
Teknik detaylar
Varsayılan değer: | belirtilmemiş |
---|---|
Geri dönüş değeri: | Bir öğenin metin rengini temsil eden bir Dize |
CSS Sürümü | CSS1 |
Daha fazla örnek
Örnek
Bir <p> öğesinin metin rengini döndürün:
alert(document.getElementById("myP").style.color);
İlgili Sayfalar
CSS eğitimi: CSS Metni
CSS referansı: color özelliği
❮ Stil Nesnesi