HTML - Backgrounds




HTML Backgrounds

You might have seen many webpages with different background colors, Besides, there are many webpages with fascinating background images.

So, if you don’t do anything, then html background will be white by default.

However, if you want to change the background with some different colors or even images.

For example −

The bgcolor attribute is used to give the desirable background color to your web page.

<tagname bgcolor="color_value"...>

Similarly, you can also define the background image as −

<tagname background="Image URL"...>

By default, your webpage background is white in color.

HTML provides the following two good ways to decorate the background part of a web page.

  • Decorate Html Background with Colors

  • Decorate Html Background with Images

HTML Background Colors

The background-color attribute is used to control the background of an HTML element, specifically page body and table background.

Following is the syntax to use background-color attribute with any HTML tag −

Syntax

<tagname style="background-color:color_value;">

HTML Background Image

The background-image property specifies an image to use as the background of an element.