background-image - HTML CSS CSS Property

HTML CSS examples for CSS Property:background-image

Description

The background-image CSS property sets the element background image.

The following table summarizes background-image property.

Item Value
Default value: none
Applies to:All elements
Inherited: No
Animatable: No.

Syntax

The syntax of the property is as follows:

background-image:      url | none | initial | inherit

Property Values

The following table describes the values of this property.

Value Description
url background image location url.
noneDefault value. If specified, no background image will be displayed.
initial Sets this property to its default value.
inherit takes the value of its parent element background-image property.

The example below shows the background-image property.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of CSS background-image property</title>
  <style type="text/css">
      body {<!--   w  ww  .  j  a v  a  2 s  . c o  m-->
      background-image: url("https://www.java2s.com/style/demo/Opera.png");
    }
  </style>
 </head>
 <body>
  <h1>This a heading</h1>
  <p>This is a paragraph.</p>
 </body>
</html>

Related Tutorials