Javascript examples for CSS Style Property:color
The color property sets or gets the color of the text.
Value | Description |
---|---|
color | Sets the color of the text. |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | not specified? |
Return Value: | A String, representing the text-color of an element |
CSS Version | CSS1 |
Set the text-color for different elements:
<!DOCTYPE html> <html> <body> <p id="myP" style="color:red;">This is an example paragraph.</p> <button type="button" onclick="myFunction()">Return text color of p</button> <script> function myFunction() {/* ww w . j ava 2 s .c o m*/ document.getElementById("myP").style.color = 'blue'; } </script> </body> </html>