CSS works by associating rules with HTML elements. These rules govern how the content of specified elements should be displayed. A CSS rule contains two parts: a selector and a declaration.
CSS declarations sit inside curly brackets and each is made up of two parts: a property and a value, separated by a colon. You can specify several properties in one declaration, each separated by a semi-colon
-
How to specify colors
-
Color terminology and contrast
-
Background color
The color property allows you to specify the color of text inside an element. You can specify any color in CSS in one of three ways:
-
rgb values These express colors in terms of how much red, green and blue are used to make it up. For example: rgb(100,100,90)
-
hex codes These are six-digit codes that represent the amount of red, green and blue in a color, preceded by a pound or hash #sign. For example: #ee3e80
-
color names There are 147 predefined color names that are recognized by browsers. For example: DarkCyan
When picking foreground and background colors, it is important to ensure that there is enough contrast for the text to be legible.
- Low contrast
- Meduim contrast
- High contrast