Search code examples
htmlcssgmailhtml-email

Gmail: elements bigger than the size defined in inline css styles


So I'm coding html of an newsletter and i'm using the inline styles because of restrictions, so my "table layout" is broken because have elements with size bigger than the defined. I realize that an element with 170px of height defined, and inside them have an tag with 170px of height defined, so why using inspect i can see that this have 172px, i think Gmail is ignoring something.

I make a gif to show this in inspector: https://i.sstatic.net/KnXEz.gif

My JSfiddle with my html: http://jsfiddle.net/wtkd/ygfn6qka/ (the boxes with images of mario shows where layout breaks) If you don't want to see in JSfiddle:

  <table width="700" align="center" style="background-image: url('http://www.image.test.com/images/bg.jpg'); background-color: #ededed; background-position: center top; background-repeat: no-repeat; margin:0;padding:0;padding: 0; width: 700px; margin: 0 auto;">
<tr width="600" style="border-collapse:collapse;border-spacing:0;">
  <td style="border-collapse:collapse;border-spacing:0;">
    <table width="600" align="center" border="0" cellpadding="0" cellspacing="0" style=
    "border-collapse:collapse;border-spacing:0;">
      <thead width="600" style="border-collapse:collapse;border-spacing:0;">
        <tr width="600"height="150" style="border-collapse:collapse;border-spacing:0;">
          <th width="600" style="border-collapse:collapse;border-spacing:0;">
            <img src="http://www.image.test.com/images/header.png" width="600" height="151">
          </th>
        </tr>
        <tr height="104">
          <th style="height:104px; border-bottom: 5px #ededed solid;">
            <img src="http://www.image.test.com/images/update.png" width="600" height="104">
          </th>
        </tr>
      </thead>
      <tbody width="600">
        <tr height="170">
          <th height="170">
            <a style="height:170px;" href="http://www.test.com/motorola-droid-turbo/65466-moto-maxx-chega-oficialmente-brasil-preco-r-xxxx.htm" target="_blank"><img src="http://www.image.test.com/images/moto-maxx.png" width="600" height="170"></a>
          </th>
        </tr>
        <tr height="180">
          <th height="170">
            <a style="height:170px;" href="http://www.test.com/jogos/65442-explosivo-trailer-gameplay-gta-v-confirma-modo-primeira-pessoa.htm" target="_blank"><img src="http://www.image.test.com/images/gta-v.png" width="600" height="170"></a>
          </th>
        </tr>
        <tr>
          <table width="600" height="340" align="center" border="0" cellpadding="0" cellspacing="0" style=
            "border-collapse:collapse;border-spacing:0;">
            <tr>
              <th height="170" style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;">
                <a style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/moto-x/65400-analise-review-smartphone-motorola-novo-moto-x-2014.htm" target="_blank"><img src="http://www.image.test.com/images/moto-x.png" width="200" height="170"></a>
              </th>
              <th height="170" style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;">
                <a style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/iphone-6/64640-analise-apple-iphone-6-review.htm" target="_blank"><img src="http://www.image.test.com/images/iphone.png" width="200" height="170"></a>
              </th>
              <th rowspan="2" height="340" style="width: 200px; height: 340px;border-collapse:collapse;border-spacing:0;">
                <a style="width: 200px; height: 340px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/jogos/65339-personagens-super-mario-viram-brindes-mcdonalds-brasileiro.htm" target="_blank"><img src="http://img.elo7.com.br/product/original/62C89A/painel-mario-bros.jpg" width="200" height="340"></a>
              </th>
            </tr>
            <tr width="400" height="170">
              <th height="170" colspan="2" style="border-collapse:collapse;border-spacing:0;">
                <a style="width:400px;height:170px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/celular/65283-dinossauros-9-celulares-marcaram-epoca.htm" target="_blank"><img src="http://cdn.bgr.com/2013/11/super-mario-3d-world.jpg" width="400" height="170"></a>
              </td>
            </tr>
          </table>
        </tr>
        <tr>
          <table width="700" align="center" border="0" cellpadding="0" cellspacing="0" style=
              "border-collapse:collapse;border-spacing:0;background:#ededed;">
            <tr align="center" height="170" style="border-collapse:collapse;border-spacing:0;">
              <th height="170">
                <a href="http://www.test.com/cinema/65416-30-filmes-2015-voce-querer-ver-cinemas-estreias-lancamentos.htm" target="_blank"><img src="http://www.image.test.com/images/filmes.png" width="600" height="170"></a>
              </th>
            </tr>
            <tr height="180" align="center" style="border-collapse:collapse;border-spacing:0;">
              <td colspan="2" style="width:400px;height:170px;border-collapse:collapse;border-spacing:0;">
                <img src="http://www.image.test.com/images/grupo-nzn.jpg" width="600" height="180">
              </td>
            </tr>
          </table>
        </tr>
      </tbody>
    </table>
  </td>
</tr>

Someone can help about this?


Solution

  • You need to put display:block; inline on all your img tags.