bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/CSS/CSS Foundations
CSS•CSS Foundations

CSS Text Color

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind CSS Text Color?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___: blue;
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The CSS Text Color Property
Text Color and Background Color
CSS Text Formatting

CSS Text Formatting

CSS has a lot of properties for styling and formatting text.

CSS Text Color

The color property is used to set the color of the text. The color is specified by:

  • a color name - like "red"
  • a HEX value - like "#ff0000"
  • an RGB value - like "rgb(255,0,0)"

Look at CSS Color Values for a complete list of possible color values.

The default text color for a page is defined in the body selector.

Example

Formatted code
body {
  color: blue;
}
h1 {
  color: green;
}
h2 {
  color: red;
}

Live preview

Text Color and Background Color

In this example, we define both the background-color property and the color property:

Example

Formatted code
body {
  background-color: lightgrey;
  color: blue;
}
h1 {
  background-color: black;
  color: white;
}
div {
  background-color: blue;
  color: white;
}

Live preview

Important: High contrast is very important for people with vision problems. So, always ensure that the contrast between the text color and the background color (or background image) is good!

The CSS Text Color Property

PropertyDescription
colorSpecifies the color of text

Previous

CSS Outline Offset

Next

CSS Text Alignment