View video tutorial

HTML Background Image

HTML

Any HTML element can have background image.

HTML background-image


It is a background set on a element.

Any content will be at the front of background image.

background-image is a CSS property, url("myimage.jpg") is used to set the image location.

Learning with HTML Editor "Try it Now"

You can edit the HTML code and view the result using online editor.

Example

<!DOCTYPE html>
<html>

<head>
   <title>HTML Img - HTML Images</title>
   <meta charset="utf-8" />
   <style>
      body {
         background-image: url("background_img01.png");
         background-repeat: no-repeat;
         background-attachment: fixed;
         background-size: cover;
      }
   </style>
</head>

<body>

   <div>
      <section>
         <h2>Introduction</h2>
         <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
            industry's standard dummy text ever since the 1500s</p>
      </section>
   </div>
   <div>
      <section>
         <h2>Introduction</h2>
         <p>Contrary to popular belief, Lorem Ipsum is not simply random text. 
            It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. 
            Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the 
            more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of 
            the word in classical literature, discovered the undoubtable source.Lorem Ipsum is simply dummy text 
            of the printing and typesetting industry. Lorem Ipsum has been the
            industry's standard dummy text ever since the 1500s</p>
      </section>
   </div>

</body>

</html>
Try it Now »

Click on the "Try it Now" button to see how it works.