HTML Element Style How to - Add div in right top position in td table cell








Question

We would like to know how to add div in right top position in td table cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
td.triangle {<!--   w w  w  .  j  a v a2 s  .c om-->
  position: relative;
  width: 100px;
  height: 100px;
  background: green;
}

td.triangle div {
  position: absolute;
  right: 0;
  top: 0;
  width: 10px;
  height: 10px;
  background: red;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td class="triangle">
        <div></div>
      </td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: