Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

W3.CSS Colors

Colors Made Easy

Colors are an important part of web design.

W3.CSS makes it easy to add colors to any HTML element.

London

London is the capital of England.

Example

<div class="w3-container w3-blue">
  <h2>London</h2>
  <p>London is the capital of England.</p>
</div>
Try it Yourself »

Background Colors

W3.CSS color classes can be used to set the background color of any HTML element.

Red

Green

Blue

Example

<div class="w3-panel w3-red">
<p>Red</p>
</div>

<div class="w3-panel w3-green">
<p>Green</p>
</div>

<div class="w3-panel w3-blue">
<p>Blue</p>
</div>
Try it Yourself »
Class Color
w3-red Red
w3-green Green
w3-blue Blue
w3-black Black

The class name tells you the color.


Text Colors

Use w3-text-color classes to change the color of text.

Red Text

Green Text

Blue Text

Example

<h3 class="w3-text-red">Red Text</h3>
<h3 class="w3-text-green">Green Text</h3>
<h3 class="w3-text-blue">Blue Text</h3>
Try it Yourself »

Border Colors

Border colors use classes beginning with w3-border-.

Red border

Green border

Blue border

Gray border

Black border

Example

<div class="w3-panel w3-border w3-border-red">Red border</div>
<div class="w3-panel w3-border w3-border-green">Green border</div>
<div class="w3-panel w3-border w3-border-blue">Blue border</div>
<div class="w3-panel w3-border w3-border-gray">Gray border</div>
<div class="w3-panel w3-border w3-border-black">Black border</div>
Try it Yourself »

Note

The colors gray and grey are interchangeable in all W3.CSS classes.



Hover Colors

W3.CSS can change colors when the mouse pointer moves over an element.

The w3-hover-color classes define the background hover color for any HTML element:

London

London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.

Example

<div class="w3-container w3-orange w3-hover-red">
  <h2>London</h2>
  <p>London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.</p>
</div>
Try It Yourself »

Example

<button class="w3-button w3-black w3-hover-red">Red</button>
<button class="w3-button w3-black w3-hover-green">Green</button>
<button class="w3-button w3-black w3-hover-blue">Blue</button>
Try it Yourself »

Combine Colors

Background and text colors can be combined with other W3.CSS classes.

This makes it easy to create attractive user interface elements (like information cards).

Paris

Discover art, architecture, food, and history.

Example

<div class="w3-card">
  <div class="w3-container w3-indigo">
    <h2>Paris</h2>
  </div>

  <div class="w3-container">
    <p>Discover art, architecture, food, and history.</p>
    <button class="w3-button w3-indigo w3-hover-black">Explore Paris</button>
  </div>
</div>
Try it Yourself »


Color Classes

W3.CSS includes a wide range of predefined colors.

The standard color classes are designed to work well with white or black text.


Pale Colors

W3.CSS also provides pale variations of Red, Yellow, Green, and Blue.

Examples

<div class="w3-container w3-pale-red">Pale Red</div>
<div class="w3-container w3-pale-yellow">Pale Yellow</div>
<div class="w3-container w3-pale-green">Pale Green</div>
<div class="w3-container w3-pale-blue">Pale Blue</div>
Try it Yourself »

Red


Build with Color

Colors are most useful when they help communicate meaning and organize content.

Below is an example of how colors can communicate status without changing the structure of the HTML.

Success

Your changes were saved.

Warning

Please check your information.

Error

Something went wrong.


Special Colors

White

Paper

Danger

Warning

Note

Info

Success


More W3.CSS Colors

W3.CSS also includes additional color libraries, themes, and color tools.

Color Themes Color Libraries Color Generator


What You Have Learned

W3.CSS makes it easy to use colors without writing CSS color values.

  • w3-color sets a background color
  • w3-text-color sets a text color
  • w3-border-color sets a border color
  • w3-hover-color sets a hover color

More Examples

The w3-color and w3-text-color classes can be used to color any HTML element:


Backgrounds:

London

London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.


London

London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.


London

London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.

Example

<div class="w3-container w3-red">
  <h2>London</h2>
  <p>London is the most populous city in the United Kingdom,
  with a metropolitan area of over 9 million inhabitants.</p>
</div>

<div class="w3-container w3-yellow">
  <h2>London</h2>
  <p>London is the most populous city in the United Kingdom,
  with a metropolitan area of over 9 million inhabitants.</p>
</div>

<div class="w3-container w3-gray">
  <h2>London</h2>
  <p>London is the most populous city in the United Kingdom,
  with a metropolitan area of over 9 million inhabitants.</p>
</div>
Try It Yourself »

Cards:

A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars are designed to run primarily on roads, to have seating for one to eight people, to typically have four wheels. (Wikipedia)


Buttons:


Tables:

Name Points
Jill Smith 50
Eve Jackson 94
Adam Johnson 67

Color libraries

In addition to standard W3.CSS colors, W3.CSS can also use colors from a lot of different color libraries:

Windows Colors:

Lime
Green
Olive
Emerald
Teal
Steel
Cyan
Blue
Indigo
Cobalt
Violet
Mauve
Pink
Magenta
Red
Orange
Amber
Yellow
Brown
Taupe
Sienna
Crimson

Click here to Learn more about Windows colors


Fashion Colors:

Flame
Greenery
Marina
Primrose
Yellow
Neutral Gray
Shaded
Spruce
Navy
Peony
Tawny
Port

Click here to Learn more about fashion colors


Highway Colors:

Red
Green
Blue
Yellow

Click here to Learn more about color libraries


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

-->