English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete CSS Properties List

CSS background-image attribute usage and example

CSS background-The image attribute sets the background image of the element. It usually uses a shorthand notationBackgroundAttribute is more convenient.

The following table summarizes the usage context and version history of this attribute.

Default value:none
Applicable to:All elements
Inheritance:None
Animated:No.Please see Animation properties.
Version:CSS 1,2,3
JavaScript syntax:    
object    object.style.backgroundImage="url(image.gif)"

background-The syntax of image usage

The syntax of this attribute is as follows:

background-image: url | none | initial | inherit

The following example demonstrates how to use background-image attribute.

body {background-image: url("images/pattern.jpg");}
Test to see‹/›

Warning: Internet Explorer 8And earlier versions do not support multiple background images on a single element.

Attribute value

The following table describes the values of this attribute.

ValueDescription
urlThe location path of the image resource used as the background image.
noneDefault value. If specified, the background image will not be displayed.
initialSet this attribute to its default value.
inheritIf specified, the associated element uses its parent element's background-Computed value of the image attribute.

Browser compatibility

background-Browser compatibility of the image attribute, all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1+

  • Opera 3.5+

Further reading

Please refer to the following tutorials:CSS background,CSS3Background.

Related attributes:background,background-attachment,background-color,background-clip,background-origin,background-position,background-repeat,background-size.