back to index

HTML Background Image

Background Image

A background image for a p element:

You can specify background images
for any visible HTML element.
In this example, the background image
is specified for a p element.
By default, the background-image
will repeat itself in the direction(s)
where it is smaller than the element
where it is specified. (Try resizing the
browser window to see how the
background image behaves.)

Background Image

By default, the background image will repeat itself if it is smaller than the element where it is specified, in this case the body element.

background repeat

By default, the background image will repeat itself if it is smaller than the element where it is specified, in this case the body element.

Background Cover

Set the background-size property to "cover" and the background image will cover the entire element, in this case the body element.

Background Stretch

Set the background-size property to "100% 100%" and the background image will be stretched to cover the entire element, in this case the body element.