Little Web Hut

CSS 2.1 Reference: background-image Property

CSS background-image Property
Syntax
selector {background-image: value;}
  • value is specified by using a URI or one of the following keywords: none or inherit.
Usage

The background-image property is used to specify the element's background image.

This property is specified by using a URI, or a keyword, according to the syntax shown above. A background-color can also be specified which will be displayed in the event that the background image is not available or if the background image does not occupy the entire background area.


CSS Example: The background-image properties are set for both the <body> tag and the <h1> tag.
  body {background-image: url("../images/floatingball.gif");}
  h1 {background-image: url("../images/dots.gif");}
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style

Keywords
  • none - Do not display a background image.
  • inherit - The inherit keyword is used to specify that the value for this property should be taken from the parent element. If inherit is used with the root element, then the initial value for this property will be used.
Applies To All elements
Inherited No
Initial Value none


background-image Property Examples
Test It HTML StyleTest It HTML StyleTest It HTML5 StyleThe background-image properties are set for both the <body> tag and the <h1> tag.