Marko Marko - 1 year ago 77
CSS Question

Default CSS values for a fieldset <legend>

I'm trying to use a

as a title inside a

In browsers other than IE, the
is positioned on the top border of the
, with the text perfectly centered on the line.

alt text

I'm trying to reset it's position so that it sits just like any other element. i.e. an

Here's the CSS I have so far.

fieldset legend {
margin: 0;
padding: 0;
position: static;
border: 0;
top: auto; left: auto;
float: none;
display: block;
font-size: 14px;
line-height: 18px;

But the legend is still perfectly centered on the line.

Yes, I can add a margin/padding/top coordinate but I want to know if the browser has any default values for the element that trigger this layout. I want to then, override these values.

Tested in Firefox (3.6.10), Chrome (6.0.472.63), Safari (5.0.2)

I'll leave this question open for another week just in case someone HAS been able to style
elements. If no solutions are found I'll accept @jnpcl's answer.

Answer Source

Simply put, it is not possible across browsers to position the LEGEND element in a Fieldset.

Workaround: wrap the text from <legend> in a <span>, then reposition the <span>.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download