CSS - table and image height issue


I have a table, and one of the columns displays a preview to a document. The preview is about 1000px in height, but I want the row to be limited to 100px in height, and the user can scroll to see the rest of the preview, or just click on the link to open the document in Word Online.

With the samples below, the row height keeps adjusting to fit the whole image.

Any help is greatly appreciated.

Here is a link to my sample on w3schools

Here is the HTML I am using:
<!DOCTYPE html>
table, th, td {
    border: 1px solid black;

ex1 {
    max-height: 50px;
    overflow: auto;

  <tr >
    <td class="ex1"><img src="https://www.clicktorelease.com/tmp/google-svg/image.svg" height="250px"/></td>
    <td >$100</td>


Open in new window

Who is Participating?
Jan LouwerensConnect With a Mentor Software EngineerCommented:
Try adding a div to the table cell, and style on that:

    <td class="ex1"><div><img src="https://www.clicktorelease.com/tmp/google-svg/image.svg" height="250px"/></div></td>

Open in new window

.ex1 div {
    max-height: 50px;
    overflow: auto;

Open in new window

maaknplanAuthor Commented:
Thanks Jan, your solution works great.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.