corroded
corroded

Reputation: 21604

fieldset legend text-align right bug in firefox

is there a way to align a fieldset legend in firefox to the right? I thought it was just my styles but apparently even with an example online the FF fieldset ignores the text-align: right:

http://www.quackit.com/html/tags/html_fieldset_tag.cfm (works in chrome)

Upvotes: 2

Views: 7643

Answers (4)

user151496
user151496

Reputation: 1985

i am late to answer, but i found this question via google and thought that this might help someone in future

in order to position the legend anyhow you like horizontally, all you have to do is set its width property to 100% and then treat its child elements as if they were inside a one-line block

so, for example, if you want to align the contents to the right, do

    label{
      width:100%;
      text-align:right;
    }

of course, don't forget to be careful about label's parent width to avoid any misbehavings

Upvotes: 1

Simon
Simon

Reputation: 3727

The align attribute of legend has been deprecated since HTML 4.01. However aligning the legend element using float: left; and float: right; seems to work fairly well across browsers, though you might need to add some margin to the first element after the legend element.

Upvotes: 3

Boris Zbarsky
Boris Zbarsky

Reputation: 35074

There's no obvious way to do this in CSS (and in particular, CSS can't really describe legend/fieldset styling at all, so the fact that any of it works is a miracle), but <legend> has an attribute named align that you can set to right like so:

<fieldset>
  <legend align="right">My stuff</legend>
</fieldset>

to get the behavior you want in Firefox. I'm surprised some people are seeing it aligned right on that testcase; there are no provisions for aligning a legend right in Gecko except for that align attribute and direction: rtl fieldsets.

Upvotes: 4

vlad saling
vlad saling

Reputation: 375

I found out, that Firefox supports something like this

text-align:-moz-right;

Perhaps you could try this out - it might make text-align work in older version of FF.

Upvotes: 0

Related Questions