The HTML <body> bgcolor Attribute is used to define a Background color of a Document.
Note: It is not supported by HTML5
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: In this example, we simply set the bg color of the body to green.
HTML
<!DOCTYPE html>
< html >
< body bgcolor = "green" >
< h2 >GeeksforGeeks</ h2 >
< p > It is a Computer Science portal For Geeks </ p >
</ body >
</ html >
|
Output:

HTML <body> bgcolor Attribute
Example: This example describes the HTML <body> bgcolor Attribute by specifying the text as green & background as orange color.
HTML
<!DOCTYPE html>
< html >
< head >
< title > HTML body Bgcolor Attribute </ title >
</ head >
< 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 >
</ html >
|
Output:

HTML <body> bgcolor Attribute
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
- Microsoft Edge