Colors HOME

Introduction to CSS colors and how they work on the web

Welcome to CSS Colors

Colors are one of the most important aspects of web design. CSS provides multiple ways to define colors, from simple named colors like red and blue to precise numeric formats like #FF6347 and rgb(255, 99, 71).

Understanding how colors work in CSS gives you complete control over the visual appearance of your web pages — from backgrounds and text to borders, shadows, and gradients.

💡
CSS supports over 140 named colors, plus millions of colors through numeric formats like HEX, RGB, and HSL.

Color Format Overview

CSS offers several ways to specify colors. Each format has its own strengths and use cases. Here are all the formats you can use:

FormatExampleDescription
Named ColortomatoUse a predefined CSS color name
HEX#FF63476-digit hexadecimal (Red, Green, Blue)
HEX (short)#F003-digit shorthand hexadecimal
RGBrgb(255, 99, 71)Red, Green, Blue values (0–255)
RGBArgba(255, 99, 71, 0.5)RGB with Alpha transparency
HSLhsl(9, 100%, 64%)Hue, Saturation, Lightness
HSLAhsla(9, 100%, 64%, 0.5)HSL with Alpha transparency

Try It — Change the Color

Pick a color and see how it looks as a CSS background. Switch between different formats to see how the same color is represented:

Live Preview
<!DOCTYPE html>
<html>
<body>

<div style="
  background-color: #FF6347;
  color: #000000;
  padding: 40px;
  text-align: center;
  font-size: 24px;
  border-radius: 12px;
">
  I have a beautiful background!
</div>

</body>
</html>
I have a beautiful background!

Common CSS Colors

Here are 24 of the most commonly used CSS colors. Click any color to see its values:

#FF0000
Redrgb(255, 0, 0)
#008000
Greenrgb(0, 128, 0)
#0000FF
Bluergb(0, 0, 255)
#FFFF00
Yellowrgb(255, 255, 0)
#00FFFF
Cyanrgb(0, 255, 255)
#FF00FF
Magentargb(255, 0, 255)
#FFA500
Orangergb(255, 165, 0)
#800080
Purplergb(128, 0, 128)
#FFC0CB
Pinkrgb(255, 192, 203)
#00FF00
Limergb(0, 255, 0)
#008080
Tealrgb(0, 128, 128)
#000080
Navyrgb(0, 0, 128)
#800000
Maroonrgb(128, 0, 0)
#808000
Olivergb(128, 128, 0)
#FF7F50
Coralrgb(255, 127, 80)
#FA8072
Salmonrgb(250, 128, 114)
#FFD700
Goldrgb(255, 215, 0)
#4B0082
Indigorgb(75, 0, 130)
#EE82EE
Violetrgb(238, 130, 238)
#40E0D0
Turquoisergb(64, 224, 208)
#DC143C
Crimsonrgb(220, 20, 60)
#D2691E
Chocolatergb(210, 105, 30)
#4682B4
SteelBluergb(70, 130, 180)
#FF6347
Tomatorgb(255, 99, 71)

How Colors Work in Web Design

Colors in CSS are used in many properties. Here are the most common ones:

/* Background color */
body { background-color: #f0f0f0; }

/* Text color */
h1 { color: navy; }

/* Border color */
.card { border: 2px solid #3498db; }

/* Box shadow with color */
.button { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }

/* Gradient backgrounds */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Semi-transparent overlays */
.overlay { background-color: rgba(0, 0, 0, 0.5); }

Color in Typography

Choosing the right text color is crucial for readability. The contrast between text and background colors must meet accessibility standards — at least 4.5:1 for normal text and 3:1 for large text (WCAG 2.1 guidelines).

Good Contrast ✅
Dark on Light
Good Contrast ✅
Light on Dark
Poor Contrast ❌
Light on Light

Color Psychology in Web Design

Colors carry psychological meanings and can influence how users perceive your website:

Red
Energy, Urgency, Passion
Blue
Trust, Calm, Professional
Green
Growth, Nature, Success
Yellow
Optimism, Warmth, Caution
Purple
Luxury, Creativity, Mystery
Teal
Balance, Sophistication
🎯
Next Steps: Explore the other tutorials in this section to learn about CSS color names, color values, color groups, shades, the color picker, and color mixing!