CSS: COLOR
Color can really bring your pages to life.
How to specify colors?
- Foreground 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.
- 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.
- color names: There are 147 predefined color names that are recognized by browsers.
- Background Color: CSS treats each HTML element as if it appears in a box, and the background-color property sets the color of the background for that box. You can specify your choice of background color in the same three ways you can specify foreground colors: RGB values, hex codes, and color names.
Contrast
When picking foreground and background colors, it is important to ensure that there is enough contrast for the text to be legible.
- Low Contrast: Text is harder to read when there is low contrast between background and foreground colors.
- High Contrast: Text is easier to read when there is higher contrast between background and foreground colors.
- Medium Contrast: For long spans of text, reducing the contrast a little bit improves readability.
You can reduce contrast by using dark gray text on a white background or an off-white text on a dark background.
HSL Colors
- hue: Hue is the colloquial idea of color. In HSL colors, hue is often represented as a color circle where the angle represents the
color, although it may also be shown as a slider with values from 0 to 360.
- saturation: Saturation is the amount of gray in a color. Saturation isrepresented as a percentage. 100% is full saturation and 0% is a shade of gray.
- ligh tness: Lightness is the amount of white (lightness) or black (darkness) in a color. Lightness is represented as a percentage.
0% lightness is black, 100% lightness is white, and 50% lightness is normal. Lightness is sometimes referred to as luminosity.