elibraryportal Logo

CSS Background Color

background property is used to background effects on element or page.

Types of Background Property

There are Five CSS background properties that is.

  1. background-color
  2. background-image
  3. background-repeat
  4. background-attachment
  5. background-position

1) CSS background-color

In CSS the background-color property is define the background color of the element.

Test it Now




2) CSS background-image

The background-image property is used to set an image as a background of an element.

Test it Now

3) CSS background-repeat

background-image property repeats the background image horizontally and vertically.

The background looks better if the image repeated horizontally only.

background-repeat: repeat-x;

Test it Now

background-repeat: repeat-y;

Test it Now

4) CSS background-attachment

The background-attachment property is used to specify if the background image is fixed or scroll with the rest of the page in browser window. If you set fixed the background image then the image will not move during scrolling in the browser.

Test it Now

5) CSS background-position

background-position property is used to initial position of the background image.the background image is placed on the top-left of the webpage.

Some following positions are:

  1. top
  2. bottom
  3. center
  4. left
  5. right
Test it Now
Next TopicCSS Border