Monday, January 2, 2012

CSS: Colors



By Richard York

Colors

CSS has a number of options for specifying colors, ranging from a 216-color, web-safe palette to the full range of colors available in the RGB format, a total of 16,777,216 colors! More specifically, those options are as follows:
  • Color keywords: These enable you to specify a color by its name.
  • RGB values: These enable you to specify a color via a Red, Green, Blue representation, which provides access to millions of colors.
  • RGB Percentage: This option is the same as RGB but uses percentages.
  • RGBA (RGB with Alpha channel [available in CSS 3]): The RGB palette is used with the addition of an alpha channel to specify transparency.
  • Hexadecimal: This enables you to specify a color by a special hexadecimal number.
  • Shorthand Hexadecimal: This is a shortened representation of hexadecimal numbers; it is limited to a special 216-color, web-safe palette.
Each method is a means of accomplishing the same thing: specifying a color. You can use these methods to specify text color, border color, or background color. Next, you see what each of these methods looks like when used in the context of a style sheet rule.

No comments: