- Home
- /
- CSS Colors
CSS Tutorial
Introduction
CSS Properties
CSS Designing
CSS Advance Topics
CSS FAQs
- Home
- /
- CSS Colors
CSS Colors
The color property in CSS is used to define the text color, text decoration color, and even the border color of HTML elements.
Syntax
selector {
color: value;
}
Example:
/* Set paragraph text color to dark green */
p {
color: darkgreen;
}
Color by Name
CSS supports named colors like blue
, red
, green
, purple
, black
, white
, and many more.
Example:
Welcome to Learn With Arshyan

Color using Hexadecimal (#RRGGBB)
A hex code start with #
followed by 6 characters representing red, green, and blue.
Example:
Arshyan’s Courses
Explore New Skills
Grow Your Career

RGB – Red, Green, Blue
PGB values range from 0 to 225 for each color channel.
selector {
color: rgb(red, green, blue);
}
Example:
Learn With Arshyan – Let's Start Coding!

RGBA – RGB with Opacity
RGBA adds an alpha value (opacity) from 0 (transparent) to 1 (opaque).
selector {
color: rgba(red, green, blue, alpha);
}
Example:
Transparent Learning with Arshyan

HSL – Hue, Saturation, Lightness
HSL stands for:
- Hue (0-360): Color type (e.g., red, blue, green)
- Saturation (0%-100%): Color intensity
- Lightness (0%-100%): Lightness or darkness
selector {
color: hsl(hue, saturation, lightness);
}
Example:
Design Bright with Arshyan!

HSLA – HSL with Opacity
HSLA is HSL + alpha channel for transparency.
selector {
color: hsla(hue, saturation, lightness, alpha);
}
Example:
Learning Never Looked So Soft

Quick Tips
- Used named colors for quick styling.
- Prefer hex or RGB/HSL for precise control.
- Use RGBA or HSLA to create transparency effects.
- Color accessibility matters: ensure good contrast between text and background.