Background-Color

The default background color is white. We can change this with the style attribute. Here's how to change the default background color from white to lightgrey:

HTML file: Displayed by browser:
<body style="background-color:lightgrey;">
  <h1>This is a heading</h1>
  <p>This is a paragraph.</p>
</body>

This is a heading

This is a paragraph.

The old bgcolor attribute, supported in older versions of HTML, is no longer valid with HTML5.

Back buttonTable of ContentsNext button