Skip to content
Related Articles

Related Articles

Improve Article

HTML <body> bgcolor Attribute

  • Last Updated : 21 Sep, 2021

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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

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:

The HTML <body> bgcolor Attribute is used to define a Background color of a Document.



Syntax:

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

Attribute Values:

  • color_name: It specifies the name of the Background color of the Document.
  • hex_number: It specifies the hex code of the Background color in the Document.
  • rgb_number: It specifies the rgb value of the Background color in the Document

Example:

HTML




<!DOCTYPE html>
<html>
  
<head>
  <title>
    HTML body Bgcolor Attribute
  </title>
</head>
  
<!-- body tag starts here -->
  
<body text="green" bgcolor="orange">
  <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:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera
  • Edge



My Personal Notes arrow_drop_up
Recommended Articles
Page :