liveBook · Manning

Padding

As explained in Web Design Playground

The inner spacing between an element's content and its border.

Padding is the breathing room inside an element: whitespace placed between its content and its border. Like a picture mount around a photo, it stops text or images from feeling crowded. section 9.1 section 9.5

09_01.png

Use the box diagram to locate padding: it sits outside content, inside the border, and before the margin. section 9.1

Set padding one side at a time when each edge needs different space:

Four sides, one declaration

Use the shorthand in top, right, bottom, left order: .pullquote { padding: 1em 1.5em .75em 1.25em; } This gives the pull quote different amounts of inner space on each side. section 9.5

Padding can also make navigation easier to scan. Adding padding-right to inline-block list items creates horizontal separation, so labels do not run together. section 9.5 section 9.6

element {
    padding-top: top-value;
    padding-right: right-value;
    padding-bottom: bottom-value;
    padding-left: left-value;
}

Use this four-property pattern when you want to control each padding edge separately. section 9.5

How Web Design Playground covers it

How deep it goes
Defines padding within the box model and demonstrates side-specific properties, measurement units, shorthand, and navigation spacing.
Examples
Shows a pull quote with unequal side padding and an unordered-list navigation menu spaced with padding-right.
What you can do after
Apply it via CSS properties or shorthand to add controlled inner spacing around element content.
How it connects
Connects padding to the CSS box model, content, borders, margins, whitespace, and navigation menus.

Also explained in

Compare how 19 books explain padding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.