It seems that fieldset defaults to 100% width of its container. Is there any way that you can have the field set just be as big as the widest control inside the fieldset?
A fieldset is as large as the parent container, just like any block-level element, if you do not give it a fixed width. So you have to make it display: inline-block . Show activity on this post.
You can't have two legends for a given fieldset, but is there a way to get a legend effect without using the <legend> tag?
The fieldset element can also contain nested fieldset elements. This is normally only required in complex forms, where there are subgroups of form elements inside larger groupings. In this example, a fieldset for your profile includes a nested fieldset for contact details.
Use display: inline-block
, though you need to wrap it inside a DIV to keep it from actually displaying inline. Tested in Safari.
<style type="text/css"> .fieldset-auto-width { display: inline-block; } </style> <div> <fieldset class="fieldset-auto-width"> <legend>Blah</legend> ... </fieldset> </div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With