You can change the color of the background using CSS, or use a background image. Background colors and background images can be applied to the entire page or to individual elements. Changing background colors on individual elements helps to add highlight and color to certain areas of the page.
1. Changing Background Color
The background color of an HTML element is changed with the background-color CSS property. The background color uses the same syntax (hex code) as font colors. For example,
With this CSS, the background color of the page would be yellow.
2. Adding Background Image
Background images are a good way to create a nice looking HTML page. Using a background image, you can create a gradient effect, where one part of the page is a solid color and the color fades out or gets lighter as it stretches to the other side.
Background images appear behind other elements. This means that you can overlay all your HTML, including other images, on top of a background image.
Background images are added with the background-image CSS property. For example,
One of the features of background images is that you can tile or repeat them within a page. This means that no matter how large the visitor’s screen, the background image will always appear. Conversely, you can also choose to not repeat the background image.