CSS Colors

Introduction to Colors in CSS

CSS supports various color models: RGB, HEX, and HSL. These models define colors through different representations.

Common Color Properties

  • color: sets the text color.
  • background-color: sets the background color of an element.

Examples

/* RGB */
h1 { color: rgb(255, 0, 0); }

/* HEX */
p { color: #00ff00; }

/* HSL */
div { background-color: hsl(240, 100%, 50%); }