B. Clay Shannon B. Clay Shannon - 3 months ago 4
CSS Question

How can I get a label to right align in a table "cell" (td)?

I've got this html:

<label class="whitefont righthoralign">Search</label>

...with this CSS:

.righthoralign {
text-align: right;

...which does nothing - the label stays left aligned as before:

enter image description here

What I found here, namely this:

.right {
position: absolute;
right: 0px;
width: 300px;
border: 3px solid #73AD21;
padding: 10px;

...made things far worse.

How can I get the label to hug the right side of the cell/td in which it finds itself?


The <label> element is inline level, the width is the size of the label text by default.


label {
  display: block;
  text-align: right;


td {
  text-align: right;