Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Container Queries and Logical Properties

The padding-block property

Reference for the CSS padding-block shorthand: logical padding along the block axis, one- and two-value syntax, examples and usage notes.

The padding-block shorthand sets the space inside an element, between its content and its border, at the start and end of the block axis. In horizontal text those are the top and bottom, so padding-block: 1rem 2rem means the same as padding-top: 1rem; padding-bottom: 2rem. In vertical writing modes the padding lands on the left and right.

It sets padding-block-start and padding-block-end.

CSS
.button { padding-block: 0.5rem; padding-inline: 1rem; }

Try it

Block padding
Padding in vertical text

Syntax

CSS
padding-block: <'padding-top'>{1,2};
  • Initial value: 0
  • Applies to: all elements except table row groups, rows, column groups and columns, and elements with display values that ignore padding
  • Inherited: no
  • Percentages: relative to the inline size of the containing block
  • Animatable: yes
  • Computed value: as specified, with lengths made absolute

Values

Value Description
One value Applied to both block-start and block-end padding.
Two values The first is block-start, the second block-end.
<length> A fixed size. Negative values are invalid.
<percentage> A share of the containing block's inline size, even though the property is on the block axis.

Usage notes

  • No auto, no negatives. Padding is never negative and cannot be auto, unlike margins.
  • Padding is inside the background. The element's background and border enclose the padding, which is why padding makes buttons feel larger while margins do not.
  • Inline elements. On a non-replaced inline element, block padding is painted but does not change the line height, so it can overlap neighboring lines. Use inline-block when you need it to take space.
  • Box sizing. With the default box-sizing: content-box, padding adds to the element's size. With border-box it comes out of the set size.
  • Percentages surprise people. padding-block: 10% is based on the container's width in horizontal text, which is the basis of the classic aspect-ratio padding trick.

Browser support

Supported in all current browsers.