B. Clay Shannon B. Clay Shannon - 1 year ago 74
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?

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download