fieldset legend text-align right bug in firefox

corroded picture corroded · May 4, 2011 · Viewed 7.2k times · Source

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)

Answer

Boris Zbarsky picture Boris Zbarsky · May 4, 2011

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.