This question already has an answer here:
According to the several references on the web, it is not possible to position a legend. So it is suggested to wrap it with span:
<legend><span>Foo</span></legend>
Then we can position the span inside the fieldset. but then when I want to add a border on top of the fieldset, there is a gap for the legend. Luckily, I've found that adding border to the legend also fixes this little, tiny gap but that's ugly solution (as everything else with css). Do you have any more valid solutions to this problem?
note: I've found the solution concurrently, after I've started writing this question, so I want to still ask it.
You can use margin-bottom "-50px" for legend and padding-top "50px" for fieldset so do not overlap.
Use an outline instead of a border: http://jsfiddle.net/leaverou/gtNnT/
The OP almost answered his own question: wrapping does the trick, but it's the other way around. Use:
I think this will work
Give border to the legend tag
I know this is an old question, but I got this page when I googled "fieldset legend position", and I really couldn't find a good answer.
The legend just won't behave!, so the best solution I found was to position it absolute and have a padding top on the fieldset. JSFildle example: http://jsfiddle.net/carlosmartinezt/gtNnT/356/
I ended up using just div elements. In the end, I just need the border and the text over the border, that's it.