Has anyone encountered a strange issue while building an HTML table for an HTML email? Whenever I insert an image into a <td>
, it causes the cell to expand to its maximum width, affecting all the columns to the right by resizing them to their minimum width. Surprisingly, the Google Chrome Inspector tool reveals that the image width is much wider than its actual size. I have tried resizing the image to 100x136px, but the <td>
still expands to 1078px. Even after testing with different images, the same problem persists. What could possibly be causing this? Below is the code snippet I am working on:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
table {
width: 100%;
margin: 20px auto;
border-collapse: collapse;
}
td {
border: 1px solid black;
}
.header {
height: 150px;
}
.bar {
height: 40px;
}
.greeting {
height: 300px;
}
.itemRow {
height: 250px;
}
.footer {
height: 75px;
}
.measure {
height: 25px;
}
img {
}
</style>
</head>
<body>
<table>
<tr class="header">
<td colspan="2" class="crest"><img src="crest.jpg" alt="" /></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="bar">
<td colspan="14"></td>
</tr>
<tr class="greeting">
<td colspan="14"></td>
</tr>
<tr class="itemRow">
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
</tr>
<tr class="measure">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="itemRow">
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
</tr>
<tr class="measure">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="itemRow">
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
<td colspan="2"></td>
</tr>
<tr class="footer">
<td colspan="12"></td>
<td colspan="1"></td>
<td colspan="1"></td>
</tr>
</table>
</body>
</html>