Open In App

HTML <body> bgcolor Attribute

Last Updated : 29 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

HTML <body> bgcolor Attribute is used to define the Background color of a Document. you can change your background color by using this.

Note: It is not supported by HTML5

Syntax:

<body bgcolor="color_name | hex_number | rgb_number">

Parameters:

  • color_name: It specifies the name of the Background color of the Document as red, green, yellow, etc.
  • hex_number: It specifies the hex code of the Background color in the Document as #RRGGBB.
  • rgb_number: It specifies the RGB value of the Background color in the Document as rgb(255, 255, 255).

Example 1: In this example, we simply set the bg color of the body to green.

HTML




<!DOCTYPE html>
<html>
<!-- body tag starts here -->
 
<body bgcolor="green">
    <h2>GeeksforGeeks</h2>
 
    <p> It is a Computer Science portal For Geeks </p>
 
</body>
<!-- body tag ends here -->
 
</html>


Output:

HTML bgcolor Attribute 

Example 2: This example using hex code for background color in HTML.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title> HTML body Bgcolor Attribute </title>
</head>
<!-- body tag starts here -->
 
<body text="green" bgcolor="#FFA500">
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>
            HTML <body> bgcolor Attribute
        </h2>
 
        <p> It is a Computer Science portal For Geeks </p>
 
    </center>
</body>
<!-- body tag ends here -->
 
</html>


Output:

HTML bgcolor Attribute 

Supported Browsers:

  • Google Chrome 1
  • Microsoft Edge 12
  • Firefox 1
  • Opera 12.1
  • Safari 1


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads