HTML <body> bgcolor Attribute Last Updated : 02 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The bgcolor attribute in HTML was traditionally used to set background colors for elements such as <body>, <table>, <td>, and <tr>. It supports named colors, hex codes, and RGB values. However, since it's deprecated in HTML5, over 90% of modern developers now prefer using CSS's background-color property for better styling control and cleaner code. Note: It is not supported by HTML5 Syntax<body bgcolor="color_name | hex_number | rgb_number">ParametersAttributeDescriptioncolor_name Specifies the name of the background color (e.g., red, green, yellow)hex_number Specifies the hex code of the background color (e.g., #RRGGBB)rgb_number Specifies the RGB value of the background color (e.g., rgb(255, 255, 255))Examples of HTML bgcolor attributeExample 1: In this example, we simply set the bg color of the body to green. index.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> OutputOutputExample 2: This example using hex code for background color in HTML. index.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> OutputOutput Browser Support Attributebgcolor✓✓✓✓✓Desktopv1v12v1v1v15Mobilev18–v4v1v14 HTML <body> bgcolor Attribute Comment More infoAdvertise with us Next Article HTML bgcolor Attribute H hritikbhatnagar2182 Follow Improve Article Tags : Web Technologies HTML HTML-Attributes Similar Reads HTML <col> bgcolor Attribute The HTML <col> element bgcolor attribute was used in HTML to set background colors for table columns. It is deprecated in HTML 4.01 and not supported in HTML5. Instead, CSS should be used to style table columns with the background-color property. Syntax: <col bgcolor= "color_name | hex_numb 2 min read HTML <th> bgcolor Attribute The bgcolor attribute in the HTML <th> (table header) tag is used to set the background color of a table header cell. You can specify colors using color names, hexadecimal codes, or RGB values. Note: It is not supported by HTML5. Syntax:<th bgcolor="color_name | hex_number | rgb_number"> 2 min read HTML <td> bgcolor Attribute The HTML <td> bgcolor attribute is used to specify the background color of a table cell. It basically, Specify the background color with a hexadecimal code for precise coloring and offers limited color choices compared to modern CSS styling. Note: It is not supported by HTML5. Syntax:<td b 2 min read HTML <tr> bgcolor Attribute The HTML <tr> bgcolor Attribute is used to specify the background color of a table row. This attribute accepts color values such as color names, hex codes, or RGB values, allowing for easy customization of the background color for individual rows in an HTML table.Note: It is not supported by H 2 min read HTML | <colgroup> bgcolor Attribute The HTML <colgroup> bgcolor attribute is used to specify the background color of a colgroup element. It is not supported by HTML 5. Syntax: <colgroup bgcolor= "color_name | hex_number | rgb_number"> Attribute Values: color_name: It sets the text color by using the color name. For example 1 min read HTML | <tbody> bgcolor Attribute The HTML tbody bgcolor Attribute is used to specify the background color of a table body(tbody). It is not supported by HTML 5. Syntax: <tbody bgcolor= "color_name | hex_number | rgb_number"> Attribute Values: color_name: It sets the text color by using the color name. For example "red". hex_n 1 min read Like