My objective is to style fieldsets with a border, position the legend at the top, and give it a background color that spans the full width of the fieldset.
I began by referencing an article on how to make a legend fill up the full width within the fieldset, which led me to experiment with this jsfiddle: http://jsfiddle.net/pdgreen/wcYXX/0.
While the initial design looked satisfactory, I realized that without padding for the fieldset, the form elements were too close to the borders. Adding padding resulted in this updated version: http://jsfiddle.net/pdgreen/wcYXX/1/.
The content displayed properly, but the legend title no longer stretched across the entire width of the fieldset.
In an attempt to resolve this issue, I enclosed the content within a div
to introduce padding: http://jsfiddle.net/pdgreen/wcYXX/2/. However, this approach necessitated the additional presence of a div
.
Is there a method to achieve the appearance seen in the third fiddle without requiring the extra div
?