I have a
<table>
<tr>
<td><span style="margin-left: 48px; width: 20px;">2</span></td>
</tr>
</table>
The span seems to have a margin but the width does not work. Is there a way I can make this work? Note that I thought of using a <div> but from what I understand it might work but it's not allowed inside a <td>.
span is inline by default. For it to understand the width it needs to be at least inline-block.
So add the following styles to your css-file:
td span {
display: inline-block;
}
P.s. Mind that display: inline-block; works from ie8 and higher.
<table>
<tr>
<td><span style="margin-left: 48px; width: 20px; display: block;">2</span></td>
</tr>
</table>
Add display: block; and then the <span /> will resize according to the given pixels on the width property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With