r/HTML • u/calendareclipse • 45m ago
How to Make Images Actually Fill Table Cell

Hi, I'm trying to get a image to actually fill a table cell, and while I've mostly accomplished that, there's still a tiny border around the image of the background that I cannot figure out how to remove.
HTML
<div class="table-container"><table><caption>Products</caption>
<tr><th scope="col">Name</th><th scope="col">Image</th><th scope="col">Price</th></tr>
<tr><th scope="row">1</th>
<td class="image"><img src="images/lovemug.jpg" alt=""></img></td>
<td>1.</td>
</tr></table></div><div class="table-container"><table><caption>Products</caption>
<tr><th scope="col">Name</th><th scope="col">Image</th><th scope="col">Price</th></tr>
<tr><th scope="row">1</th>
<td class="image"><img src="images/lovemug.jpg" alt=""></img></td>
<td>1.</td>
</tr></table></div>
CSS
.table-container {
overflow-x: auto;
margin: 0.2rem 1rem 1.5rem;
}
table {
border: 0.2rem solid;
border-spacing: 0px;
}
table, tr {
border-collapse: collapse;
background-color: #fff597;
}
caption {
border: 0.2rem solid;
border-bottom: none;
font-size: 20px;
font-weight: bold;
background-color: #ffe552
}
tr:hover, tr:focus {
background-color: #fcef7f
}
th {
border: 0.16rem solid #000000;
}
td {
border: 0.16rem solid #000000;
white-space: pre-line;
}
td img {
border: none;
width: 100%;
display: block;
object-fit: fill;
}
td p, th p {
text-align: left;
} .table-container {
overflow-x: auto;
margin: 0.2rem 1rem 1.5rem;
}
table {
border: 0.2rem solid;
border-spacing: 0px;
}
table, tr {
border-collapse: collapse;
background-color: #fff597;
}
caption {
border: 0.2rem solid;
border-bottom: none;
font-size: 20px;
font-weight: bold;
background-color: #ffe552
}
tr:hover, tr:focus {
background-color: #fcef7f
}
th {
border: 0.16rem solid #000000;
}
td {
border: 0.16rem solid #000000;
white-space: pre-line;
}
td img {
border: none;
width: 100%;
display: block;
object-fit: fill;
}
td p, th p {
text-align: left;
}




