Open In App

HTML <body> background Attribute

Improve
Improve
Like Article
Like
Save
Share
Report

The HTML <body> background attribute is used to specify a background image or color for the entire web page’s body. You can provide either a URL for an image or a color code to customize the background of the HTML body element.

Note: It is not supported by HTML5 Instead of using this attribute we use CSS background property.

Syntax: 

<body background="URL">

Attribute Values:

It contains the value i.e. URL Which specifies the address of the background Image. 

Attribute Values

Description

Absolute URL

It points to another website.

Relative URL

It points to a file within a website.

Example 1: 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML body Background Attribute
    </title>
</head>
 
<!-- body tag starts here -->
 
<body background=
 
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>HTML
 
            <body> background Attribute
        </h2>
 
        <a href="#">
            It is a Computer Science portal For Geeks
        </a>
    </center>
</body>
<!-- body tag ends here -->
 
</html>


Output: 

Example 2: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>GeeksforGeeks Background Example</title>
    <style>
        h1 {
            margin-top: 50px;
        }
    </style>
</head>
 
<body style="
background-image: url('https://media.geeksforgeeks.org/gfg-gg-logo.svg'); background-repeat: no-repeat;">
 
    <h1>Welcome to GeeksforGeeks!</h1>
    <p>
        This is a simple example showcasing <br>
        the use of the HTML body background <br>
        attribute with a background image from a <br>
        URL.
    </p>
 
</body>
 
</html>


Output:

Screenshot-2024-01-02-090200



Last Updated : 12 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads