XML technologies / ePUB / CSS essentials / Important CSS properties / Margins and spacing

(Excerpt from “E-Books mit ePUB ─ Von Word zum E-Book mit XML” by Dr. Victor Wang)

The table lists the main CSS properties for margins and spacing, with possible values and examples.

margin-right
margin-left

Outer spacing

Sets an individual outer margin. See margin

Values

<Außenabstand-Breite> | inherit

Example

see margin

margin-top
margin-bottom

Outer spacing

Sets an individual outer margin. See margin

Values

<Außenabstand-Breite> | inherit

Example

see margin

margin

Outer spacing

Sets outer margins. Possible forms:

1) One value for all sides: top, right, bottom, left

2) Two values: vertical top/bottom and horizontal right/left

3) Three values: top, horizontal sides, bottom

Values

<Außenabstand-Breite>{1,4} | inherit

Example

margin: 20px 10px 30px 10px;

padding-top
padding-right
padding-bottom
padding-left

Inner spacing

Sets individual inner spacing. See padding

Values

<Innenabstand-Breite> | inherit

Example

see padding

padding

Inner spacing

Sets the current element’s inner spacing. Compare margin

Values

<Innenabstand-Breite>{1,4} | inherit

Example

padding: 10pt 0;

   

Digression: The box model

The box model for margins and spacing

Figure: The box model for margins and spacing

   

 

 

 

back to top