How to create a fixed background image on a web page

Updated: 07/13/2023 by Computer Hope

To specify a background image in the body element of an HTML (hypertext markup language) web page, follow these steps.

Tip

This page describes how to do specify a fixed background image in the HTML body element, which is deprecated in HTML5. For a modern solution using CSS (cascading style sheets), see: How to create a web page as a single background image not tiled.

Set a background image using the HTML body element

Add the bgproperties="fixed" code into the body element, as shown below. Next, add the background="location" attribute to the body tag, where location is the relative or absolute URL (uniform resource locator) of the image.

<body background="bg.gif" bgcolor="#000000" bgproperties="fixed">

In the above example, background="bg.gif" is setting the background picture using the bg.gif and then bgproperties="fixed" sets the images as a fixed background that will not scroll.