Background Images

  • Like colors, images can be set as background for any applicable tag.
  • If we need to set a background image for the whole web page, was set that background in the body tag.
  • Backgrounds set for an inner tag will override the one set for the outer if any.

 

Example:

   
<!doctype>   
<html>
<body style="background-image: url(myimages/picture1.jpg)">

    <h1 style="background-color: yellow">Background  Image Example</h1>

    <div>
        <p>This  paragraph background will be the same like the one set in the
        body i.e. lightgray.</p>
        <p style="background-color: lightgreen">While  this paragraph's
        background color will be light green,  as inner tag settings has the
        priority.</p>
    </div>
</body>
</html> 

 

The result will be: