Page Widget How to - Create Vertical CSS Tab with h3 and div








Question

We would like to know how to create Vertical CSS Tab with h3 and div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
h3, .content {<!-- w  w  w  . j a va  2  s.co  m-->
  float: left;
}

h3 {
  clear: both;
  margin-right: 10px;
  border-right: 1px solid red;
  padding-right: 10px;
  margin-bottom: 10px;
}
</style>
</head>
<body>
  <h3 id="tab1">tab1</h3>
  <div class="content">content for tab1</div>
  <h3 id="tab2">tab2</h3>
  <div class="content">content for tab2</div>
  <h3 id="tab3">tab2</h3>
  <div class="content">content for tab2</div>
</body>
</html>

The code above is rendered as follows: