CSS Layout How to - Create Vertical layout without using breaking elements








Question

We would like to know how to create Vertical layout without using breaking elements.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#menu {<!--   ww  w.j av  a  2s . c  om-->
  width: 300px;
}

#menu a {
  display: block;
  background: #ccc;
  color: #000;
  padding: 10px 0;
  text-align: center;
  margin-bottom: 2px;
}
</style>
</head>
<body>
  <div id="menu">
    <a href="something1">Page 1</a> 
    <a href="something2">Page 2</a> 
    <a href="something3">Page 3</a>
  </div>
</body>
</html>

The code above is rendered as follows: