HTML Background colors are added to the website to make it more attractive.
info: Background colors can be added to elements like header(h1,h2,h3,h4,h5,h6), body, paragraph(p), tables etc.
CSS uses border color more effectively. For example- You can add a color to div, classes etc. This is covered in detail in our CSS tutorial.
Syntax: bgcolor=value or background-color:value
Note/Warningbgcolor attribute in <body> is deprecated in HTML5. This means that you should not use - <body bgcolor="red">. You can use CSS for this.
Example of Background Colors to body, headers, and paragraph
Example
<h2style="background-color:tomato;">Background color of h2 tag is tomato</h2><h2style="background-color:blue;">h2 tag background color is dodgerblue</h2><pstyle="background-color:orange;">
Background color added to the paragraph. You should always give a good background color which blends with other HTML elements properly.
</p>