CSS Background Image

CSS Background Image

background-image The attribute specifies the image used as the element's background.

By default, the image will repeat to cover the entire element.

Example

The background image of the page can be set like this:

body {
  background-image: url("paper.gif");
}

Try It Yourself

Example

This example shows the text and background image of theWrong Combination.Text is difficult to read:

body {
  background-image: url("bgdesert.jpg");
}

Try It Yourself

Note:When using a background image, please use an image that will not interfere with the text.

You can also set a background image for a specific element, such as the <p> element:

Example

p {
  background-image: url("paper.gif");
}

Try It Yourself