CSS TutorialLesson #17

Background Image

The `background-image` property specifies an image to use as the background of an element.

CSS background-image

The background-image property specifies an image to use as the background of an element.

By default, the image is repeated so it covers the entire element.

Example

Example Code

css
Try it Yourself
body {
  background-image: url("paper.gif");
}

Example

Example Code

css
Try it Yourself
body {
  background-image: url("bgdesert.jpg");
}

Note: When using a background image, use an image that does not disturb the text.

The background image can also be set for specific elements, like the <p> element:

Example

Example Code

css
Try it Yourself
p {
  background-image: url("paper.gif");
}

The CSS Background Image Property

PropertyDescription
background-imageSets the background image for an element

Video: CSS Background Images


Interactive Code Examples

CSS Example 1

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 2

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 3

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview: