XML technologies / CSS / CSS Cookbook / Forms / Adjusting the space around a form

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

You want to change the default space around a form.

Solution

Set the margin of the form element to zero and adjust its padding to suit your needs instead (see the following figure):

form {
 margin: 0;
 padding: 1em 0;
 border: 1px dotted red;
 /* verwendet, um die Auswirkungen der Innenabstände zu verdeutlichen */
}

Custom padding has been defined for the form

Figure: Custom padding has been defined for the form.

Discussion

Integrating forms into a web page’s design often requires adjusting the space between the form and the other page elements. Most commonly, the padding above and below the form is set to suit the situation.

See also

The recipe Styling input elements on styling input elements.

  

 

 

 

back to top