Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove spacing in a TD element that contains a list [duplicate]

Tags:

html

css

I'd like to remove the padding present in the first row in the table, so it is the same height as the second row. I'm not sure where the padding is coming from, as I've set the padding to zero in the td ul and li elements.

http://jsfiddle.net/d9no97vL/

<table>
  <tr>
    <td><ul><li>abc</li><li>def</li></ul></td>
    <td>this row is too wide</td>
  </tr>
  <tr>
    <td></td>
    <td>this row is just right</td>
  </tr>
</table>

And the css:

ul li { display: inline; margin: 0; padding: 0; }
table { border-collapse: collapse; border: 1px solid black; }
td { padding: 0px; border: 1px solid black; }
like image 211
Nicholas Palko Avatar asked Jan 18 '26 02:01

Nicholas Palko


1 Answers

That's because of the default padding/margin on the ul element (dictated by the browser style sheets). Add the following:

ul { margin: 0; padding: 0; }

DEMO

like image 67
mattytommo Avatar answered Jan 19 '26 16:01

mattytommo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!