Javatpoint Logo
Javatpoint Logo

HTML Background Image

The <background> attribute in the HTML document is used to specify the background image on a HTML page or a table. You can pass the path of an image as a value of background attribute to set the image of your HTML page or table.

Syntax

Note: The Background attribute is not supported in HTML5. Use the following syntax of CSS:

Examples: The following examples set the background image in different styles:

Example 1: This example uses the background attribute with the body tag for displaying the image as a background of the web page.

Test it Now

Output:

HTML Background Image

Example 2: This example uses the background attribute with the table tag for displaying the image as a background of html table.

Test it Now

Output:

HTML Background Image

Example 3: This example uses the CSS syntax for the background-image property of the style attribute with the body tag.

Test it Now

Output:

HTML Background Image

Example 4: This example uses the CSS syntax for the background-image property in the style attribute with the table tag.

Test it Now

Output:

HTML Background Image

Example 5: This example uses the CSS syntax for the background-repeat and background-size property of the style attribute with the body tag.

Test it Now

Output:

HTML Background Image

Browser Support

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
Background ImageYesYesYesYesYes

Next TopicHtml Button Type





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA