CHAPTER 19

image

Margin and padding

Margins and padding are used to adjust the position of an element and to create space around it.

Padding

Padding is the space between an element’s content and its border. It is set using the padding properties shown here. These properties do not inherit and can be applied to any element.

padding (1-4) | padding-top | padding-right |padding-bottom | padding-left :   <length> | <percentage>

There are four properties for setting the padding on each side individually. In the following example, the vertical (top, bottom) margins will be 10 pixels, and the horizontal (right, left) margins will be zero.

padding-top:    10px; ...

Get CSS Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.