How to position block elements in a td
cell
The answers provided do a great job to right-align text in a td
cell.
This might not be the solution when you're looking to align a block element as commented in the accepted answer. To achieve such with a block element, I have found it useful to make use of margins;
General syntax
selector {
margin: top right bottom left;
}
Justify right
td > selector {
/* there is a shorthand, TODO! */
margin: auto 0 auto auto;
}
Justify center
td > selector {
margin: auto auto auto auto;
}
/* or the short-hand */
margin: auto;
Align center
td > selector {
margin: auto;
}
JSFiddle example
Alternatively, you could make you td
content display inline-block
if that's an option, but that may distort the position of its child elements.