HTML bgcolor attribute

HTML bgcolor attribute: The HTML bgcolor attribute is used for setting the background color of an HTML page. There are about totally 256 colors in the HTML colors.

HTML bgcolor attribute

In HTML bgcolor attribute the color can be “name” or “hexavalue”. All the major browser support the bgcolor attribute. But the HTML5 does not support the <bgcolor> attribute. And we should not RGB value in body bgcolor, because rgb( ) is used only in CSS only. It will not work in HTML.

Syntax: <body bgcolor=”color”>

Example:



<html>
  <head>
    <title>Body bgcolor Attribute example</title>
  </head>
  <body bgcolor="#FAAFBE">
    <h1>This webpage has colored background.</h1>
  </body>
</html>

Output:

HTML bgcolor attribute

Example:

<html>
  <head>
    <title>Body bgcolor Attribute example</title>
  </head>
  <body bgcolor="#E41B17">
    <h1>This webpage has colored background.</h1>
  </body>
</html>

Output:

HTML bgcolor red