As the title says, I have an HTML table with some columns. In one of these columns, which has width: auto I would like to display the text left aligned and and an image/icon right aligned and floating, because the image is optional (i.e. some rows may not have it and I want the text to use all the available space in the <td> in that case).
Here's the JSFiddle example: https://jsfiddle.net/4d8foL32/2/
Basically the code is this:
<tr>
<td>4000.4</td>
<td>Lemon soda<img src=""></td><!-- This is the line -->
<td>10/10/2021</td>
<td>London, United Kingdom</td>
<td>Waiting</td>
</tr>
img {
float: right;
padding-right: 2px;
}
There are 2 issues I would like to solve:
I would like the image always to be vertically centered on the row
When reducing the browser window width (and hence the table width), the text doesn't split on a new line keeping the image on the right.
The image should keep a small padding on the left to not go over the text. Which is the best way to handle this?

