Word-Wrapping Table

Word-Wrapping Table

by Hilarius Doren

HTML

<table border="1">
    <tr>
        <td>1</td>   <td>Thisisareallylonglinewhichshouldwraptothenextonebutdoesntbecausethatsnotthedefaltbehavior</td>
        
    </tr>
    <tr>
        <td>2</td>
        <td>This line will wrap correctly since it has words separated by spaces. However, because there is another long line, it will span as long as the first one and only then wrap.</td>
    </tr>
</table>

CSS

table {
    width: 100%;
    table-layout: fixed;
}
td {
    word-wrap: break-word;
}