HTML Element Style How to - Position a div below an image








Question

We would like to know how to position a div below an image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.content {<!--from  w w w  .j  av  a 2s. c om-->
  height: 400px;
  width: 100%;
}
img {
  display: block;
}
</style>
</head>
<body>
  <header>
    <img class="forumheader"
      src="http://www.java2s.com/style/download.png" />
  </header>
  <div class="content">I am a content.</div>
</body>
</html>

The code above is rendered as follows: