शैली रंग संपत्ति
उदाहरण
विभिन्न तत्वों के लिए टेक्स्ट-रंग सेट करें:
document.getElementById("myH2").style.color = "#ff0000";
document.getElementById("myP").style.color = "magenta";
document.getElementById("myP2").style.color = "blue";
document.getElementById("myDiv").style.color = "lightblue";
परिभाषा और उपयोग
रंग गुण टेक्स्ट का रंग सेट या लौटाता है।
ब्राउज़र समर्थन
Property | |||||
---|---|---|---|---|---|
color | Yes | Yes | Yes | Yes | Yes |
वाक्य - विन्यास
रंग संपत्ति वापस करें:
object.style.color
रंग संपत्ति सेट करें:
object.style.color = "color|initial|inherit"
सम्पत्ति की कीमत
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 |
टेक्निकल डिटेल
डिफ़ॉल्ट मान: | निर्दिष्ट नहीं है |
---|---|
प्रतिलाभ की मात्रा: | एक स्ट्रिंग, एक तत्व के पाठ-रंग का प्रतिनिधित्व करता है |
सीएसएस संस्करण | सीएसएस 1 |
और ज्यादा उदाहरण
उदाहरण
<p> तत्व का टेक्स्ट-रंग लौटाएं:
alert(document.getElementById("myP").style.color);
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस टेक्स्ट
सीएसएस संदर्भ: रंग संपत्ति
❮ स्टाइल ऑब्जेक्ट