HTML Form How to - Place two adjacent divs in a button tag








Question

We would like to know how to place two adjacent divs in a button tag.

Answer


<!DOCTYPE html>
<html>
<head>
<style>
.div1 {<!--from  ww w .j  a v a 2 s  .  com-->
  display: inline;
  border: 1px solid red;
}

.div2 {
  display: inline;
  border: 1px solid red;
}

.div3 {
  display: inline;
  border: 1px solid cyan;
}
</style>
</head>
<body>
  <button>
    <div class="div1">div1</div>
    <div class="div2">div2</div>
  </button>
  <div class="div3">
    <div class="div1">div1</div>
    <div class="div2">div2</div>
  </div>
</body>
</html>

The code above is rendered as follows: