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.
Output:
Example 2: This example uses the background attribute with the table tag for displaying the image as a background of html table.
Output:
Example 3: This example uses the CSS syntax for the background-image property of the style attribute with the body tag.
Output:
Example 4: This example uses the CSS syntax for the background-image property in the style attribute with the table tag.
Output:
Example 5: This example uses the CSS syntax for the background-repeat and background-size property of the style attribute with the body tag.
Output:
Browser Support
Element | ![]() | ![]() | ![]() | ![]() | ![]() |
Background Image | Yes | Yes | Yes | Yes | Yes |