Master CSS From Scratch

Clear, interactive, and structured CSS lessons designed for beginners.

Text Color

The color property is used to change the color of text on a web page.

You can use color names, hexadecimal values, RGB values, and other CSS color values.

How Text Color Works

HTML Text
→
color: blue;
→
Colored Text

Example 1: Color Name

CSS allows you to use predefined color names such as blue, red, and green.

CSS Code
h1 {
    color: blue;
}
Output

WELCOME TO CIIT TRAINING INSTITUTE🤓

Example 2: Hexadecimal Color

You can also specify a color using a hexadecimal value.

CSS Code
h2 {
    color: #ff0000;
}
Output

CSS Tutorial

Example 3: RGB Color

RGB values can be used to define colors using red, green, and blue values.

CSS Code
p {
    color: rgb(0, 128, 0);
}
Output

Learn CSS step by step.

Example 4: Multiple Text Colors

Different HTML elements can have different text colors.

CSS Code
h3 {
    color: purple;
}

p {
    color: orange;
}
Output

CSS Colors

Different elements can use different colors.

Common CSS Color Values

Type Example Description
Color Name blue Uses a predefined CSS color name
Hexadecimal #ff0000 Uses a hexadecimal color value
RGB rgb(0, 128, 0) Uses red, green, and blue values

Simple Explanation

color: blue; → Makes the text blue.

color: #ff0000; → Makes the text red.

color: rgb(0, 128, 0); → Makes the text green.

The color property changes only the text color of an element.

Summary

The color property is used to change the color of text. CSS supports color names, hexadecimal values, RGB values, and many other color formats.