CSS Layout How to - Create Two-column layout with ul tag








Question

We would like to know how to create Two-column layout with ul tag.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#blogWrapper {<!--from  w w  w  .j  a v a 2  s .  com-->
  width: 65%;
  height: auto;
  min-width: 45%;
  margin: 0 auto;
  border: 1px solid red;
  background-color: #EEE;
}

#blogWrapper {
  overflow: hidden;
}

#blogWrapper li {
  float: left;
  display: block;
}

#testBlogCol1 {
  width: 40%;
  height: auto;
  background-color: #DDD;
}

#testBlogCol2 {
  width: 50%;
  height: auto;
  background-color: #CCC;
}
</style>
</head>
<body>
  <ul id="blogWrapper">
    <li id="testBlogCol1">Column 1</li>
    <li id="testBlogCol2">Column 2</li>
  </ul>
</body>
</html>

The code above is rendered as follows: