top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to add a background image using css to a html page?

+1 vote
473 views
How to add a background image using css to a html page?
posted Mar 23, 2017 by Richa Patil

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Example
Set a background-image for the 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.

Tip: Always set a background-color to be used if the image is unavailable.

Default value:  none
Inherited:  no
Animatable: no. Read about animatable
Version:    CSS1 + new values in CSS3
JavaScript syntax:  object.style.backgroundImage="url(smiley.gif)

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

Example

Set multiple background images for the element:

body {
    background-image: url("img_tree.gif"), url("img_flwr.gif");
    background-color: #cccccc;
}
answer Apr 3, 2017 by Manikandan J
...