Curriculum
Course: CSS
Login

Curriculum

CSS

CSS INTRODUCTION

0/1

CSS Selectors

0/1

CSS Comments

0/1

CSS Padding

0/1

CSS Box Model

0/1

CSS Combinators

0/1

CSS Pseudo-classes

0/1

CSS Pseudo-elements

0/1

CSS Dropdowns

0/1

CSS Image Gallery

0/1

CSS Image Sprites

0/1

CSS Counters

0/1

CSS Website Layout

0/1

CSS Specificity

0/1

CSS Math Functions

0/1
Text lesson

Text Color

Text Color

The color property determines the color of text, which can be specified using:

  • A color name, such as “red”
  • A HEX value, like “#ff0000”
  • An RGB value, such as “rgb(255,0,0)”

Refer to CSS Color Values for a comprehensive list of potential color values.

The default text color for a webpage is established within the body selector.

Example

body {
  color: blue;
}

h1 {
  color: green;
}

Text Color and Background Color

In this example, we set both the background-color and color properties.

Example

body {
  background-color: lightgrey;
  color: blue;
}

h1 {
  background-color: black;
  color: white;
}

div {
  background-color: blue;
  color: white;
}

 

Attention: Adequate contrast is crucial for individuals with vision impairments. Thus, consistently verify that there is strong contrast between text and background colors (or images)!

 

The CSS Text Color Property

Property

Description

 color

Specifies the color of the text.