!DOCTYPE html> Introduction to HTML

colors

Introduction to CSS Colors

CSS Colors Guide

CSS Color Formats

In CSS, colors can be specified in several formats. Below are some commonly used formats:

HEX Color

The HEX color code is a six-digit code representing the amount of red, green, and blue in a color. It is prefixed with a # symbol.

HEX Color Example: #3498db

RGB Color

RGB stands for Red, Green, and Blue. This format is written as rgb(red, green, blue), with each color value between 0 and 255.

RGB Color Example: rgb(46, 204, 113)

RGBA Color

RGBA is an extension of the RGB color model with an added alpha (opacity) value. The alpha value is between 0 (completely transparent) and 1 (completely opaque).

RGBA Color Example: rgba(241, 196, 15, 0.8)

HSL Color

HSL stands for Hue, Saturation, and Lightness. The hue is represented as an angle (0-360), saturation as a percentage, and lightness as a percentage.

HSL Color Example: hsl(344, 85%, 44%)

Choosing Colors for the Web

When selecting colors for a website, consider factors such as contrast, accessibility, and brand identity. Using colors with good contrast ensures readability, while considering accessibility helps all users experience your content effectively.

Experiment with different color schemes and formats to find the best combinations for your design needs.