Friday, November 2, 2012

Wrap long word in html table cell



In HTML table, different words can be  wrapped, but a long word will not be broken down. This will cause the cell width more than the width defined in CSS.

We can use  CSS
 word-wrap: break-word;
to break down a word  and  keep the  cell width fixed.

Example code:
<style type="text/css">
    table td
    {
        word-wrap: break-word;
    }
    </style>

  <table style="width: 100%; table-layout: fixed;"  cellpadding="0" cellspacing="0">
                <col width="13%" />
                <col width="18%" />
                <col width="30%" />
                <col width="21%" />
                <col width="18%" />
                    <tr>
                        <td>&nbsp;
                        </td>
                         <td>&nbsp;
                        </td>
                         <td>&nbsp;
                        </td>
                         <td>&nbsp;
                        </td>
                        < <td>&nbsp;
                        </td>
                    </tr>
            </table>

No comments:

Post a Comment