Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

css
color
background
html

How do you change the background color using CSS?

Educative Answers Team

In CSS, we use the background-color property to specify the background color of an element.

svg viewer

In the code snippet below, the entire color of the web page is set using the background-color property.

The value of the background-color property can be specified in three ways:

  1. Using RGB values e.g. rgb(250,0,0), rgb(0,250,0), etc.
  2. Using a Hexadecimal(HEX) value e.g. #FFFFFF, #000000, etc.
  3. Using a valid color name e.g. “white”, “red”, “black”, “blue”, etc.

The code snippet below sets the background color for the entire body, <div>, <h2> and <p> elements of the web page.

RELATED TAGS

css
color
background
html
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring