HTML <body> bgcolor Attribute
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 bgcolor = "green" >
< h2 >GeeksforGeeks</ h2 >
< p > It is a Computer Science portal For Geeks </ p >
</ body >
</ 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 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 >
</ html >
|
Output:
HTML bgcolor AttributeÂ
Supported Browsers:
- Google Chrome 1
- Microsoft Edge 12
- Firefox 1
- Opera 12.1
- Safari 1
Last Updated :
29 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...