Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mystery white space at the bottom of form element

When a form is put inside a div, there's always extra space at the bottom of the form for some reason. How do we get rid of that space?

In the code snippets from stack overflow, it doesn't actually show the space, but anywhere else, it does. The code below is all there is.

div {
  border: 1px solid blue;
}
form {
  border: 1px solid red;
}
<div>
  <form>
    Form
  </form>
</div>
like image 529
frosty Avatar asked Oct 18 '16 22:10

frosty


People also ask

Is white space an element?

White space (negative space) is the area between design elements. It's another tool for designers to design for the user experience (UX). Remember that white space is not necessarily white; it's just the name to indicate spaces where there are neither user interface (UI) elements nor specific content.

Why is there a gap at the bottom of my website?

The gap is caused by the margin in your body-wrapper div. margin: -85px auto -60px auto the '-60px' is the culprit (bottom-margin). Reduce or increase it to alter your gap. Save this answer.


1 Answers

You can refer to web developer tools (F12), and you'll see that a form element comes with a margin-bottom: 1em, as defined in the browser's default stylesheet:

enter image description here

You can override that by defining your own margin rule:

form { margin-bottom: 0; }
like image 108
Michael Benjamin Avatar answered Nov 10 '22 03:11

Michael Benjamin