0

how do i make table rows to be of the exactly same height? whenever the text in the <td> exceeds the limit it exand the row. How do i make it in a way that it don't do that. instead show less text here is the code

<div class="firstDiv" style="width: 200px; height: 200px;">

    <table border="1" style="border-collapse: collapse;">
        <tr style="height: 20px;">
            <th width="33%">First Name</th>
            <th width="33%">Last Name</th>
            <th width="33%">Country Of Origin OR MIG</th>
        </tr>
        <tr>
            <td>Mark</td>
            <td>Hopkins lee brimlow</td>
            <td>Not living in world right now</td>
        </tr>
    </table>
</div>
Waqar Haider
  • 929
  • 10
  • 33

2 Answers2

1

As regards multiple related content sections (vis-a-vis table cells) and a concise, "well-manicured" UI, you must have well-formed data or be willing to compromise. Per your question, the implicit assumption is that your data is not well-formed (in the amount-of-text sense) and you are therefore willing to compromise. Two suggestions:

The key with both of these suggestions is that they lock the height of each td element (and thereby the entire row) to a single text line via the white-space: nowrap.

There are of course other options for a consistent table height, but it's difficult to enumerate them all without a more explicit question.

hunteke
  • 3,648
  • 1
  • 7
  • 17
1

Try wrapping the text around a div

<div class="firstDiv" style="width: 200px; height: 200px;">

    <table border="1" style="border-collapse: collapse;">
        <tr style="height: 20px;">
            <th width="33%"><div>
            First Name
            </div></th>
            <th width="33%"><div>
            Last Name
            </div></th>
            <th width="33%"><div>
            Country Of Origin OR MIG
            </div></th>
        </tr>
        <tr>
            <td><div>
            Mark
            </div></td>
            <td><div>
            Hopkins lee brimlow
            </div></td>
            <td><div>
            Not living in world right now
            </div></td>
        </tr>
    </table>
</div>

And use height

th div, td div{
  height:40px;
  overflow:auto;
}

https://jsfiddle.net/L2awyezb/

Alaksandar Jesus Gene
  • 6,523
  • 12
  • 52
  • 83