Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make td (table cell) height to be the same as an < a> (link element) height?

I have created a simple example https://jsfiddle.net/9usfctbp/ that contains the issue.

There is a code from fiddle:

<table>
  <tr>
    <td>
      <a href="#">
        Link
      </a>
    </td>
  </tr>
</table>
a {
  display: block;
  font-size: 16px;
  line-height: 16px;
}

Expected result: td has height 16px the same as a link.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Actual result: td has height 18px that is 2px more than a link height.

>Solution :

try removing the padding from the td elements :

/* if you only want to keep the same height */
td {
   padding-top: 0;
   padding-bottom: 0;
}

/* or remove the padding from all edges */

td {
   padding: 0;
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading