Page Widget How to - Set background around image








Question

We would like to know how to set background around image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.first-img {<!--from ww w.  j a v a 2 s.co  m-->
  padding: 30px;
  width: 500px;
  background: url('http://www.java2s.com/style/download.png');
}
</style>
</head>
<body>
  <div class="first-img">
    <img src="http://www.java2s.com/style/download.png" alt="image01" />
  </div>
</body>
</html>

The code above is rendered as follows: