basics of website design banner photo

HTML

HTML 5

CSS 2.1

CSS 3

Reference

CSS background-image Property

The background-image property allows you to display an image as the background for an element.

Possible Values

  • url - the path to the location of the image to be used, written as :
    background-image: url(‘path to image file’)
  • none - no background image - the default value.
  • inherit - the background image is inherited from the parent element.

NOTE: the image path must be enclosed in single quotes.

Example code using an image with the name "clouds.jpg" located in the same folder as the page:

{background-image: url(‘clouds.jpg’)}

Result when added to a <div> element:

The image becomes the background of the element to which it is applied and other content such as text is displayed on top of the image as you can see.


CSS 2.1 Property List