CSS - background-image


Description

background-image defines a pointer to an image resource which is to be placed in the background of an element.

Possible Values

  • uri − URL of the image.

  • none − Setting background-image to none means that no background image should be used for matching elements.

  • transparent

Applies to

All the HTML elements.

DOM Syntax

object.style.backgroundImage = "Any value as defined above";

Example

Following is the example which demonstrates how to set the background image for an element.

<html>
   <head>
      <style>
         body {
            background-image: url("/css/images/css.jpg");
            background-color: #cccccc;
         }
      </style>
   </head>
   
   <body>
      <h1>Hello World!</h1>
   </body>
<html>

It will produce the following result −

css_references.htm
Advertisements