HTML Element Style How to - Add Dynamic Ellipsis








Question

We would like to know how to add Dynamic Ellipsis.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
th, td {<!-- ww w  .  j ava 2 s  .c o m-->
  width: 33%;
  border: 1px solid black;
  max-width: 200px;
}

table {
  width: 100%;
}

span {
  width: 100%;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
}
</style>
</head>
<body>
  <table>
    <thead>
      <tr>
        <th>one</th>
        <th>two</th>
        <th>three</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span>asldf lkasjdflasdkj laksdjflasdkjjf asdfasd
            asdf asd</span></td>
        <td></td>
        <td></td>
      </tr>
    </tbody>
  </table>
</body>
</html>

The code above is rendered as follows: