CSS BACKGROUND

The CSS provide several properties for styling the background of an element, like: background-colorbackground-imagebackground-repeatbackground-attachment and background-position. The following section will describe you how to use these properties to set the different styles for the backgrounds one by one.

Background Color

The background-color property is used to set the background color of an element.

The example below demonstrates, how to set the background color of a web page.

EXAMPLE

body{
    background-color: #f0e68c;
}

Colors in CSS most often specified by the following methods:

  • a HEX value – like “#ff0000”
  • an RGB value – like “rgb(255,0,0)”
  • a color name – like “red”

Categories: CSS