HTML Element Style How to - Set UL as table








Question

We would like to know how to set UL as table.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!-- w w w .  j a v a 2  s .c o  m-->
  width: 100%;
  display: table;
  table-layout: fixed;
  border-collapse: collapse;
}

li {
  display: table-cell;
  text-align: center;
  border: 1px solid pink;
  vertical-align: middle;
}
</style>
</head>
<body>
  <ul>
    <li>foo<br>foo
    </li>
    <li>barbarbarbarbar</li>
    <li>baz</li>
  </ul>
</body>
</html>

The code above is rendered as follows: