HTML Element Style How to - Wrap data in a cell








Question

We would like to know how to wrap data in a cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#nowrap td {<!--from  ww w .  ja va  2  s . c o  m-->
  width: 30px;
  white-space: nowrap;
}

#wrapped td {
  width: 30px;
}
</style>
</head>
<body>
  <table id="nowrap">
    <tr>
      <td>Some data</td>
    </tr>
  </table>
  <table id="wrapped">
    <tr>
      <td>Some data</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: