Problem
The problem is that in Chrome, Opera and IE (!?) The following works: it does not work in Firefox:
fieldset>legend { display: table; float: none; margin: 0 auto; }
<fieldset> <legend>Legend</legend> </fieldset>
Result in Chrome

Result in Firefox

Hacks Solutions
There are several questions, but none of them have satisfactory answers:
fieldset>legend { display: table; float: none; margin: 0 auto; } fieldset.absolute-fix { position: relative; } fieldset.absolute-fix>legend { position: absolute; left: 50%; } fieldset.margin-fix>legend { margin-left: 50%; margin-right: 50%; width: auto; transform: translate(-50%, 0) } fieldset.width-fix>legend { width: 100%; text-align: center; }
<fieldset class="absolute-fix"> <legend>Fix with absolute</legend> <p>Not centered and inconsitant styling</p> <a href="http://stackoverflow.com/a/4006871/1185053">Source</a> </fieldset> <fieldset class="attribute-fix"> <legend align="center">Fix with attribute</legend> <p>Requires use of depreciated HTML and strongly ties presentation to content.</p> <a href="http://stackoverflow.com/a/19969606/1185053">Source</a> </fieldset> <fieldset class="margin-fix"> <legend>Fix with margin</legend> <p>This is unsatisfying because there is a mis-aligned gap in the border and long legends go over several lines.</p> </fieldset> <fieldset class="width-fix"> <legend>Fix with width</legend> <p>This is unsatisfying because there is a gaping hole in the border.</p> </fieldset>
Question
Is there a way to constantly visit legend in Firefox, while preserving the style for other browsers?
html css firefox
dav_i
source share