Your code is fine. I ran some tests and the problem was with styling the <td>
tag. You didn't specify, but I am wondering if your <td>
is wrapped with <table><tr>
. If not, that is the problem.
I tested your exact code, it failed as you described. Then I changed the <td>
to a <div>
and it worked like a charm.
Then I wrapped the <td>
in a <table><tr>
... </tr></table>
and it also worked fine.
So, ensure that your <td>
is in a row, in a table, and your code should work.