I have an issue with the width of a fieldset. It's not auto adjusting to it's content. It sets the width to the width of the screen. Is there a way to set it to auto adjust to the width of the content of the fieldset?
            Asked
            
        
        
            Active
            
        
            Viewed 1e+01k times
        
    8
            
            
        - 
                    4dup of http://stackoverflow.com/questions/2302495/is-there-anyway-to-have-a-fieldset-width-only-be-as-wide-as-the-controls-in-them – cofiem Sep 08 '10 at 01:20
- 
                    2The solution didn't work for me. I had to set `fieldset{ min-width: auto; }` as fieldset uses min-width as -webkit-min-content, as mentioned in the following post - https://stackoverflow.com/questions/27660423/fieldset-width-100-of-parent. – Naren Feb 16 '18 at 10:24
5 Answers
9
            
            
        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.
 
    
    
        Frank van Wijk
        
- 3,234
- 20
- 41
- 
                    It was the width of the page for me. It couldn't have cared less about the parent. – Suncat2000 May 29 '23 at 19:34
-2
            
            
        Sett the width to 0
Hml:
<fieldset class="field">
</fieldset>
Css:
.field {
    width: 0;
}
 
    
    
        Persijn
        
- 14,624
- 3
- 43
- 72
 
     
     
     
    