CSS Text

TEXT FORMATTING

Text formatting

This text is styled with some of the text formatting properties. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters is specified. The underline is removed from this colored "Try it Yourself" link.

This text uses some text formatting attributes to set the style. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters is specified. Then from this colorful"Try it Yourself"The underline is removed from the link.

Try It Yourself

Text color

color The attribute is used to set the text color. The color is specified by the following values:

  • Color name - for example "red"
  • Hexadecimal value - for example "#ff0000"
  • RGB Values - For example "rgb(255,0,0)"

View CSS Color Values, to get a complete list of possible color values.

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

Example

body {
  color: blue;
}
h1 {
  color: green;
}

Try It Yourself

Tip:For W3C compliant CSS: If you define color properties, then you must also define background-color properties.

text color and background color

In this example, we define the background-color Properties and color Property:

Example

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

Try It Yourself