HTML Element Style How to - Add border to div rows








Question

We would like to know how to add border to div rows.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
<!--from   ww  w. ja  v a  2 s .  c o m-->
body {
  padding-top: 20px;
  padding-bottom: 40px;
}

.container {
  width: 420px;
}

div.row {
  border: 1px solid;
  border-bottom: 0px;
}

.container div.row:last-child {
  border-bottom: 1px solid;
}
</style>
</head>
<body>
  <div class="container">
    <div class="row heading">
      <div class="col-md-12">Header</div>
    </div>
    <div class="row subheading">
      <div class="col-md-12">Some text</div>
    </div>
    <div class="row footer">
      <div class="col-md-12">Footer</div>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: