I have a code very similar to this one:
table,
th {
border: 1px solid black;
}
th {
width: 200px;
/* for illustration purposes, but in reality there's no width defined */
}
th.text-right {
text-align: right;
}
th.text-left {
text-align: left;
}
.icon {
color: blue;
}
<table>
<thead>
<th class="text-left">
<span>Text</span>
<span class="icon">Icon</span>
</th>
<th class="text-right">
<span>Text</span>
<span class="icon">Icon</span>
</th>
</thead>
</table>
I need the icon to be always on the left of the text. But the problem is that the text can be aligned to left or right, and in both cases, the icon should "look" like it's part of the text, that means, it always have to leave a little space (only little) between itself and the text.
Is there a way to achieve it with CSS only and without flexbox?