HTML Element Style How to - Add round border to table cell








Question

We would like to know how to add round border to table cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
td>div {<!-- w w  w . ja va  2 s .com-->
  padding: 4px;
}

td:nth-child(even)>div {
  background: #AAA;
}

td:nth-child(odd)>div {
  background: green;
}

td.prev {
  padding: 8px 0 8px 8px;
}

td.current {
  padding: 8px 8px 8px 0;
}

td.prev>div {
  border-radius: 4px 0 0 4px;
}

td.current>div {
  border-radius: 0 4px 4px 0;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td class="prev">
        <div>Lorem Ipsum Prev</div>
      </td>
      <td class="current">
        <div>Lorem Ipsum Current</div>
      </td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: