HTML Style Background Property | Style Background Tutorial by WDH

HTML Style Background Property


Example of setting a background color with the style attribute:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body style="background-color:#1c87c9;">
    <h1>Some heading</h1>
    <p>Some paragraph for example.</p>
  </body>
</html>

Try it Yourself »

Result

Some heading

Some paragraph for example.

Add the CSS background-color property to the <body> element

The background-color property is used to change the background color. Inserting it to the <body> element you will have a full colored cover of the page.

Example of setting a background color with the CSS background-color property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document </title>
    <style>
      body {
        background-color: #1c87c9;
      }
    </style>
  </head>
  <body></body>
</html>