
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to display the background color of an element in HTML?
Use the bgcolor attribute in HTML to display the background color of an element. It is used to control the background of an HTML element, specifically page body and table backgrounds.
Note − This attribute is not supported in HTML5.
Example
You can try to run the following code to learn how to implement bgcolor attribute in HTML −
<!DOCTYPE html> <html> <head> <title>HTML Background Colors</title> </head> <body> <!-- Format 1 - Use color name --> <table bgcolor = "yellow" width = "100%"> <tr> <td> This background is yellow </td> </tr> </table> <!-- Format 2 - Use hex value --> <table bgcolor = "#6666FF" width = "100%"> <tr> <td> This background is sky blue </td> </tr> </table> <!-- Format 3 - Use color value in RGB terms --> <table bgcolor = "rgb(255,0,255)" width = "100%"> <tr> <td> This background is green </td> </tr> </table> </body> </html>
- Related Articles
- How to return the background color of an element with JavaScript DOM?
- How to set background color in HTML?
- How to change the text color of an element in HTML?
- How to set the background color for an element using jQuery?
- Set the background color of an element with CSS
- How to verify the color and background color of a web element in Selenium?
- How do we display the thickness of the border of an element in HTML?
- How to set style display of an html element in a selenium test?
- Is it possible to have an HTML canvas element in the background of my page?
- How to display HTML element with JavaScript?
- How to include an alternate text when the original element fails to display in HTML?
- Changing three.js background to transparent or another color in HTML
- How to change the background color of UIStackView?
- Add a red background color to an element to set danger action with Bootstrap
- Add a blue background color to an element to set key stuff with Bootstrap

Advertisements