Kaitlyn Wheeler
Kaitlyn Wheeler

Reputation: 3

Adjust size of HTML fieldset

I am using the <fieldset> tags for a website I am making to display information because the fieldset box makes separating the information more appealing.

The only issue is that the fieldset box spreads the width of the browser page and has lots of empty white space. Is there an attribute or way to make it so that it isn't as long across the screen?

Upvotes: 0

Views: 4103

Answers (1)

Jamie Calder
Jamie Calder

Reputation: 959

All block-level elements with unspecified size will take the full available width.

If you add some css to the fieldset to set it to display as an inline block, it will not go full width. You can also set a width there is you wanted.

fieldset{
  display: inline-block;
}

or

fieldset{
  width: 50%
}

The only issue you might have here is that the fieldset might not flow properly because it'll be inline. You could also set a width on the fieldset using CSS or wrap the fieldset in a div and set the DIVs width to whatever width you need.

Here's a codepen with examples of each: https://codepen.io/jamiecalder/pen/dyyYLVp

Upvotes: 1

Related Questions