Html image in a table without spaces

I have an html table in which I place images side by side inside td. How can I get it so that there is no space between each image? By default, all browsers seem to fit in a small space, despite the fact that there were 0 indents and margins on each table element. I do not specify the width on td, so by default it takes the width of the image inside it.

i.e:

<table>
  <tr>
    <td><img ... /></td> //no space between the td's
    <td><img ... /></td>
  </tr>
</table>
+3
source share
4 answers

Apply this css:

td, tr, img  { padding: 0px; margin: 0px; border: none; }
table { border-collapse: collapse; }

Resets all spaces to 0.

+5
source

Cell distribution and cellpadding should be 0 in the table.

<table cellspacing="0" cellpadding="0">
  <tr>
    <td><img></td> 
    <td><img></td>
  </tr>
</table>
+2
source

Take a look at the attributes cellpadding, borderand cellspacingfor the HTML tag table. If you are using XHTML or CSS, check the appropriate styles - border-collapse, paddingetc.

0
source

Another thing that can avoid unwanted space between images:

<td style="line-height:0;">
0
source

Source: https://habr.com/ru/post/1767248/


All Articles