CSS padding-block-end Property
The CSS padding-block-end property sets the padding at the logical end of an element's block axis.
Unlike physical padding properties, padding-block-end adapts to the element's writing mode. It controls bottom padding in horizontal writing modes, left padding in vertical right-to-left writing modes, and right padding in vertical left-to-right writing modes.
padding-block-end Syntax
The padding-block-end property accepts a single non-negative length or percentage value, or a CSS-wide keyword.
Basic Syntax
selector {
padding-block-end: 20px;
}
The declaration adds 20 pixels of padding at the logical block-end side.
Length Values
.box {
padding-block-end: 10px;
}
.box {
padding-block-end: 1.5rem;
}
.box {
padding-block-end: 2em;
}
.box {
padding-block-end: 3vh;
}
Lengths can use absolute or relative CSS units. Relative units are useful when spacing should respond to font sizes or viewport dimensions.
Percentage Values
.box {
padding-block-end: 5%;
}
The percentage is calculated relative to the containing block's logical width.
Calculated Values
.box {
padding-block-end: calc(1rem + 10px);
}
.box {
padding-block-end: clamp(1rem, 3vw, 2.5rem);
}
CSS functions such as calc() and clamp() can create flexible padding values.
CSS-Wide Keywords
.box {
padding-block-end: initial;
}
.box {
padding-block-end: inherit;
}
.box {
padding-block-end: unset;
}
.box {
padding-block-end: revert;
}
.box {
padding-block-end: revert-layer;
}
CSS-wide keywords must be used alone rather than combined with length or percentage values.
Property Values
| Value | Description |
|---|---|
<length> |
Sets non-negative padding using a length such as 10px, 1rem, or 2em. |
<percentage> |
Sets non-negative padding as a percentage of the containing block's logical width. |
0 |
Removes padding from the logical block-end side. |
initial |
Resets the property to its initial value of 0. |
inherit |
Inherits the computed value from the parent element. |
unset |
Resets the property to 0 because padding is not inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | 0 |
| Inherited | No |
| Applies to | All elements, except certain internal table elements |
| Computed value | Computed length or percentage |
| Animation type | By computed value type |
| Percentages | Relative to the containing block's logical width |
| Negative values | Not permitted |
| Logical axis | Block axis |
| Shorthand | padding-block |
Valid Values
.box {
padding-block-end: 0;
}
.box {
padding-block-end: 20px;
}
.box {
padding-block-end: 1.5rem;
}
.box {
padding-block-end: 5%;
}
.box {
padding-block-end: calc(1rem + 5px);
}
Invalid Values
.box {
padding-block-end: -10px;
}
.box {
padding-block-end: auto;
}
.box {
padding-block-end: 10px 20px;
}
Negative values, auto, and multiple length or percentage values are invalid for this longhand property.
How It Works
The padding-block-end property creates internal spacing between an element's content and the border on its logical block-end side.
The physical side represented by block-end depends on the element's writing mode.
Adding Block-End Padding
.panel {
padding-block-end: 30px;
background-color: #dbeafe;
border: 2px solid #2563eb;
}
In a horizontal writing mode, the panel receives 30 pixels of padding below its content.
Removing Block-End Padding
.panel {
padding-block-end: 0;
}
The logical block-end padding is removed without changing padding on the other sides.
Combining Logical Padding Properties
.panel {
padding-block-start: 10px;
padding-block-end: 30px;
padding-inline: 20px;
}
This applies 10 pixels at block-start, 30 pixels at block-end, and 20 pixels on both inline sides.
Background and Padding
.notice {
padding-block-end: 20px;
background-color: #fef3c7;
border: 1px solid #d97706;
}
By default, the background extends through the padding area, making the additional internal space part of the element's visible background.
Writing Modes and Logical Directions
The block-end side is determined by the direction in which block-level content progresses.
| Writing Mode | Block-End Side |
|---|---|
horizontal-tb |
Bottom |
vertical-rl |
Left |
vertical-lr |
Right |
sideways-rl |
Left |
sideways-lr |
Right |
Horizontal Writing Mode
.box {
writing-mode: horizontal-tb;
padding-block-end: 30px;
}
The bottom side receives 30 pixels of padding.
Vertical Right-to-Left Writing Mode
.box {
writing-mode: vertical-rl;
padding-block-end: 30px;
}
The left side receives 30 pixels of padding.
Vertical Left-to-Right Writing Mode
.box {
writing-mode: vertical-lr;
padding-block-end: 30px;
}
The right side receives 30 pixels of padding.
Text Direction
.box {
writing-mode: horizontal-tb;
direction: rtl;
padding-block-end: 30px;
}
The block-end side remains the bottom. Changing direction alone does not reverse the block axis in horizontal writing mode.
Physical vs. Logical Padding
Physical padding properties always target a fixed side. Logical padding properties adapt to writing mode.
| Property | Controls |
|---|---|
padding-bottom |
Physical bottom side |
padding-left |
Physical left side |
padding-right |
Physical right side |
padding-block-end |
Logical block-end side |
Physical Padding
.box {
padding-bottom: 30px;
}
The bottom receives padding regardless of writing mode.
Logical Padding
.box {
padding-block-end: 30px;
}
The padding moves to the physical side representing block-end in the current writing mode.
Why Use Logical Padding?
Logical padding is useful when building multilingual interfaces or components that may use horizontal or vertical text layouts.
Instead of creating separate physical padding rules for each writing mode, a single logical declaration can adapt automatically.
Interaction With padding-block
The padding-block-end property is one of the two longhand properties controlled by the padding-block shorthand.
Using the Shorthand
.box {
padding-block: 10px 30px;
}
This is equivalent to:
.box {
padding-block-start: 10px;
padding-block-end: 30px;
}
Overriding the Block-End Side
.box {
padding-block: 20px;
padding-block-end: 40px;
}
The block-start padding remains 20 pixels, while the block-end padding becomes 40 pixels.
Shorthand After Longhand
.box {
padding-block-end: 40px;
padding-block: 20px;
}
The later shorthand sets both block sides to 20 pixels, overriding the earlier block-end declaration at equal cascade priority.
Interaction With Physical Padding
.box {
writing-mode: horizontal-tb;
padding-bottom: 40px;
padding-block-end: 10px;
}
Both declarations target the bottom side in horizontal writing mode. Because they have equal cascade priority, the later logical declaration takes effect.
When combining logical and physical properties, consider both writing mode and the CSS cascade.
Percentage Padding
Percentage values for padding-block-end are relative to the containing block's logical width, not necessarily its physical width.
Horizontal Writing Mode
.container {
width: 400px;
}
.box {
padding-block-end: 5%;
}
If the containing block's logical width is 400 pixels, the block-end padding is 20 pixels.
Vertical Writing Mode
.container {
writing-mode: vertical-rl;
height: 300px;
}
.box {
padding-block-end: 10%;
}
In a vertical writing mode, the containing block's logical width corresponds to its inline size, generally its physical height. If that size is 300 pixels, the padding is 30 pixels.
Responsive Padding
.section {
padding-block-end: clamp(1rem, 4vw, 3rem);
}
The padding adjusts with the viewport while remaining between 1rem and 3rem.
Combining Percentages and Lengths
.section {
padding-block-end: calc(5% + 10px);
}
The calculated value combines a percentage of the containing block's logical width with a fixed length.
padding-block-end Example
The following example demonstrates how the logical block-end padding changes physical sides in different writing modes.
HTML Example
<div class="padding-demo">
<div class="padding-item">
<h3>Horizontal Writing</h3>
<div class="padding-box horizontal">
<span>Content</span>
</div>
</div>
<div class="padding-item">
<h3>Vertical Right-to-Left</h3>
<div class="padding-box vertical-rl">
<span>Content</span>
</div>
</div>
<div class="padding-item">
<h3>Vertical Left-to-Right</h3>
<div class="padding-box vertical-lr">
<span>Content</span>
</div>
</div>
</div>
CSS Example
.padding-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 20px;
padding: 20px;
background-color: #f1f5f9;
}
.padding-item h3 {
margin: 0 0 10px;
font-size: 16px;
}
.padding-box {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
min-height: 150px;
padding-block-end: 40px;
padding-inline: 15px;
border: 2px solid #2563eb;
background-color: #bfdbfe;
}
.padding-box span {
padding: 8px;
background-color: #fff;
}
.horizontal {
writing-mode: horizontal-tb;
}
.vertical-rl {
writing-mode: vertical-rl;
}
.vertical-lr {
writing-mode: vertical-lr;
}
Horizontal Writing
Vertical Right-to-Left
Vertical Left-to-Right
The blue background extends through the padding area. The 40-pixel block-end padding appears below the content in horizontal writing mode, to its left in vertical-rl, and to its right in vertical-lr.
Practical Content Panel
.content-panel {
padding-block-start: 1rem;
padding-block-end: 2rem;
padding-inline: 1.5rem;
border: 1px solid #cbd5e1;
background-color: #f8fafc;
}
This creates more space at the logical end of the block axis while maintaining consistent inline spacing.
Accessibility Considerations
The padding-block-end property can help maintain comfortable spacing around content in layouts that support different writing modes.
Provide Adequate Spacing
.notice {
padding-block-end: 1.5rem;
padding-inline: 1rem;
line-height: 1.5;
}
Internal spacing helps prevent text and other content from appearing crowded against an element's border.
Support Text Resizing
Relative units such as rem can help padding respond to changes in the user's preferred font size.
Support Multiple Writing Modes
.content-card {
padding-block-end: 1.5rem;
}
Logical padding helps maintain the intended spacing when content uses horizontal or vertical writing.
Avoid Content Clipping
Large padding values can reduce available space inside elements with fixed dimensions. Test layouts with enlarged text, zoom, and narrow viewports.
Important Consideration
Padding alone does not make an interface accessible. Semantic HTML, keyboard navigation, sufficient contrast, and readable text remain important.
Common Mistakes
Assuming Block-End Always Means Bottom
Block-end corresponds to the bottom in horizontal writing modes, but it maps to the left or right side in vertical writing modes.
Confusing Block-End With Inline-End
padding-block-end follows the block axis, while padding-inline-end follows the inline axis. These properties can target different physical sides.
Using Negative Values
.box {
padding-block-end: -20px;
}
Negative padding values are invalid.
Using auto
.box {
padding-block-end: auto;
}
The auto keyword is not supported for padding.
Providing Multiple Values
.box {
padding-block-end: 10px 20px;
}
This longhand property accepts only one value. Use padding-block to set both logical block sides.
Mixing Physical and Logical Declarations
Physical and logical properties may affect the same side. Their interaction depends on the writing mode and cascade priority.
Forgetting the Box Model
Padding contributes to the element's dimensions. With box-sizing: content-box, it increases the rendered size beyond a declared width or height.
Important Considerations
Keep the following points in mind when using padding-block-end:
- It controls padding at the logical end of the block axis.
- Its physical side depends on the element's writing mode.
- In
horizontal-tb, it maps to bottom padding. - In
vertical-rl, it maps to left padding. - In
vertical-lr, it maps to right padding. - Changing
directionalone does not reverse the block axis. - It accepts one non-negative length or percentage value.
- Negative values are invalid.
- The
autokeyword is invalid. - The initial value is
0. - The property is not inherited.
- Percentage values are relative to the containing block's logical width.
- It is a longhand property of
padding-block. - Later shorthand declarations can reset its value.
- Physical and logical padding properties can target the same side.
- The CSS cascade determines which conflicting declaration takes effect.
- The element's background normally extends through its padding area.
- Padding contributes to the CSS box model.
- Padding does not collapse like some margins.
- Relative units can help create responsive internal spacing.
- Logical properties are useful for multilingual and writing-mode-aware layouts.
Browser Support
The CSS padding-block-end property is Widely available in modern browsers, including current versions of Chrome, Edge, Firefox, and Safari.
It is defined by CSS Logical Properties and Values. Older browsers may not support logical padding properties, so verify compatibility when supporting legacy environments.
Physical Fallback Example
.box {
padding-bottom: 20px;
padding-block-end: 20px;
}
The physical declaration provides a fallback for horizontal writing modes when padding-block-end is unsupported.
For current compatibility information, visit Can I Use? and search for padding-block-end.
Specifications
The padding-block-end property is defined in CSS Logical Properties and Values Module Level 1.
CSS Logical Properties and Values Module Level 1
The specification defines how logical padding properties map to physical sides according to writing mode.
For additional documentation and examples, consult MDN Web Docs.
