background image

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

CSS background-image Property


Set a background-image for the <body> element:

body {
    background-image: url("paper.gif");
    background-color: #cccccc;


Definition and Usage

The background-image property sets one or more background images for an element.

The background of an element is the total size of the element, including padding and border (but not the margin).

By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.


CSS Syntax

background-image: url|none|initial|inherit;

Property Values

Value Description
url('URL') The URL to the image. To specify more than one image, separate the URLs with a comma
none No background image will be displayed. This is default
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

More Examples


Set multiple background images for the <body> element:

body {
    background-image: url("img_tree.gif"), url("img_flwr.gif");
    background-color: #cccccc;