CSS GUIDE COLOR
This document is a work in progress and is subject to change.
Summary
The color property is used the set the text color for a given element. The text color of an element may also be referred to as the foreground colour.
Applicability: | The color property can be used for all CSS elements. | |
Media Group: | Visual | |
Inherited: | Yes |
Syntax
TARGET_ELEMENT{color: #0033ff} TARGET_ELEMENT{color: red} TARGET_ELEMENT{color: rgb(0,200,0)}
Legal Values
Values can be entered in 3 ways:
Method | Range | Example |
---|---|---|
Hexadecimal (preferred) | #000000 - #ffffff | #00ff00 is green |
Color name | W3Schools Natural Langauge Color Names | green |
RGB value | 0-255 | rgb(102,204,102) is green |
See usage examples section for more details.
Mozilla Recommended Values
Usage Examples
p{color: #ff0000} /*Set paragraph text to appear red.*/
h1{color: #0000FF} /*Set h1 (level 1 heading) text to blue.*/
span{color: #0000FF} /*Sets text enclosed within span tag to appear yellow*/
Notes
Please remember to use the appropriate U.S. English spelling i.e. color and not the U.K or Canadian english spellings to ensure your CSS works.
The World Wide Web Consortium (W3C) provides a free online CSS validation service.