Google News
logo
HTML Backgrounds
The most straightforward way to change the default (white) background for a page is to use background-color on the body. HTML provides you following two good ways to decorate your webpage background.

1. Html Background Colors
2. Html Background Images
1. Html Background Colors
The bgcolor attribute is used to control the background of an HTML element, specifically page body and table backgrounds.
Example Programs
<html>
   <head>
<title>Learning HTML</title>
   </head>
   <body bgcolor="#3cb371">
   </body>
</html>


Another Program :-


<html>
    <head>
    <title>HTML Background Colors</title>
    </head>
    <body>
        <table bgcolor="#00CC00" width="100%">
        <tr><td>
        This background is Green.
        </td></tr>
        </table>
        <table bgcolor="#FF0000" width="100%">
        <tr><td>
        This background is RED.
        </td></tr>
        </table>
    </body>
</html>
Output :
HTML Structure
2. Html Background Images
The background-image property needs to be a URL to the image. This usually looks like this:
Example Programs
<html>
    <head>
    <title>Background Image</title>
    </head>
    <body background="background-image.jpg">
    </body>
</html>
 

Another Program :-


<html>
  <head>
    <title>HTML Background Images</title>
  </head>
  <body>
        <table background="sample-bg-image.jpg" width="100%" style="padding:150px 0px; color:#FFF; text-align:center; font-size:30px;">
        <tr>
        <td>
         Sample Background Image
        </td>
        </tr>
        </table>
  </body>
</html>
Output :
HTML Structure