خاصية لون النمط
مثال
اضبط لون النص للعناصر المختلفة:
document.getElementById("myH2").style.color = "#ff0000";
document.getElementById("myP").style.color = "magenta";
document.getElementById("myP2").style.color = "blue";
document.getElementById("myDiv").style.color = "lightblue";
التعريف والاستخدام
تقوم خاصية color بتعيين أو إرجاع لون النص.
دعم المتصفح
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 |
تفاصيل تقنية
القيمة الافتراضية: | غير محدد |
---|---|
قيمة الإرجاع: | سلسلة ، تمثل لون نص العنصر |
إصدار CSS | CSS1 |
مزيد من الأمثلة
مثال
إعادة لون النص للعنصر <p>:
alert(document.getElementById("myP").style.color);
الصفحات ذات الصلة
دروس CSS: نص CSS
مرجع CSS: خاصية اللون
❮ نمط الكائن