Back to home

HTML Background Images

A background image for a p element:

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 on a Page

You can specify background images
for any visible HTML element.
In this example, the background image
is specified for a div 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 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.