tags:

views:

1123

answers:

4

it seems that fieldset defaults to 100% width of its container. Is there anyway that you can have the field set just be as big as the widest control inside the fieldset ?

A: 

You can always use CSS to constrain the width of the fieldset, which would also constrain the controls inside.

I find that I often have to constrain the width of select controls, or else really long option text will make it totally unmanageable.

Jonathan Julian
but i want to have it dynamic so the fieldset will "autosize" and not be a predetermined width
ooo
+5  A: 

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>
tvanfosson
This was the clearest answer for a relative n00b and it solved my identical problem. Thanks.
Mawg
Works with FF3.6
Daok
+3  A: 

You could float it, then it will only be as wide as its contents, but you'll have to make sure you clear those floats.

Tom
+2  A: 

fieldset {display:inline} or fieldset {display:inline-block}

If you want to separate two fieldsets vertically, use a single <br/> between them. This is semantically correct and no harder than it has to be.

Superstringcheese