CSS padding-block-start Property
The CSS padding-block-start property sets the padding at the logical start of an element's block axis.
The physical side receiving padding depends on the element's writing mode. In horizontal writing modes, padding-block-start controls top padding. In vertical writing modes, it controls padding on the right or left side.
padding-block-start Syntax
The padding-block-start property accepts one non-negative length or percentage value, or a CSS-wide keyword.
Basic Syntax
selector {
padding-block-start: 20px;
}
This declaration adds 20 pixels of padding at the element's logical block-start side.
Length Values
.box {
padding-block-start: 10px;
}
.box {
padding-block-start: 1.5rem;
}
.box {
padding-block-start: 2em;
}
.box {
padding-block-start: 3vh;
}
Length values may use absolute or relative CSS units. Relative units are useful for spacing that adapts to font sizes or viewport dimensions.
Percentage Values
.box {
padding-block-start: 5%;
}
Percentage padding is calculated relative to the containing block's logical width.
Calculated Values
.box {
padding-block-start: calc(1rem + 10px);
}
.box {
padding-block-start: clamp(1rem, 3vw, 2.5rem);
}
CSS functions such as calc() and clamp() can create flexible padding values.
CSS-Wide Keywords
.box {
padding-block-start: initial;
}
.box {
padding-block-start: inherit;
}
.box {
padding-block-start: unset;
}
.box {
padding-block-start: revert;
}
.box {
padding-block-start: revert-layer;
}
CSS-wide keywords must be used alone. They cannot be combined with length or percentage values in the same declaration.
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-start 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-start: 0;
}
.box {
padding-block-start: 20px;
}
.box {
padding-block-start: 1.5rem;
}
.box {
padding-block-start: 5%;
}
.box {
padding-block-start: calc(1rem + 5px);
}
Invalid Values
.box {
padding-block-start: -10px;
}
.box {
padding-block-start: auto;
}
.box {
padding-block-start: 10px 20px;
}
Negative values, auto, and multiple length or percentage values are invalid for this longhand property.
How It Works
The padding-block-start property creates internal spacing between an element's content and the border on its logical block-start side.
The physical side represented by block-start depends on the element's writing mode.
Adding Block-Start Padding
.panel {
padding-block-start: 30px;
background-color: #dbeafe;
border: 2px solid #2563eb;
}
In a horizontal writing mode, the panel receives 30 pixels of padding above its content.
Removing Block-Start Padding
.panel {
padding-block-start: 0;
}
The logical block-start padding is removed without changing padding on the other sides.
Combining Logical Padding Properties
.panel {
padding-block-start: 30px;
padding-block-end: 10px;
padding-inline: 20px;
}
This applies 30 pixels at block-start, 10 pixels at block-end, and 20 pixels on both inline sides.
Background and Padding
.notice {
padding-block-start: 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-start side is determined by the direction in which block-level content progresses.
| Writing Mode | Block-Start Side |
|---|---|
horizontal-tb |
Top |
vertical-rl |
Right |
vertical-lr |
Left |
sideways-rl |
Right |
sideways-lr |
Left |
Horizontal Writing Mode
.box {
writing-mode: horizontal-tb;
padding-block-start: 30px;
}
The top side receives 30 pixels of padding.
Vertical Right-to-Left Writing Mode
.box {
writing-mode: vertical-rl;
padding-block-start: 30px;
}
The right side receives 30 pixels of padding.
Vertical Left-to-Right Writing Mode
.box {
writing-mode: vertical-lr;
padding-block-start: 30px;
}
The left side receives 30 pixels of padding.
Text Direction
.box {
writing-mode: horizontal-tb;
direction: rtl;
padding-block-start: 30px;
}
The block-start side remains the top. Changing direction alone does not reverse the block axis in horizontal writing mode.
Physical vs. Logical Padding
Physical padding properties target fixed sides. Logical padding properties adapt to the writing mode.
| Property | Controls |
|---|---|
padding-top |
Physical top side |
padding-right |
Physical right side |
padding-left |
Physical left side |
padding-block-start |
Logical block-start side |
Physical Padding
.box {
padding-top: 30px;
}
The top receives padding regardless of writing mode.
Logical Padding
.box {
padding-block-start: 30px;
}
The padding moves to whichever physical side represents block-start in the current writing mode.
Why Use Logical Padding?
Logical padding is useful for multilingual interfaces and components that may use horizontal or vertical text layouts.
Instead of creating separate physical padding rules for each writing mode, one logical declaration can adapt automatically.
Interaction With padding-block
The padding-block-start property is one of the two longhand properties controlled by the padding-block shorthand.
Using the Shorthand
.box {
padding-block: 30px 10px;
}
This is equivalent to:
.box {
padding-block-start: 30px;
padding-block-end: 10px;
}
Overriding the Block-Start Side
.box {
padding-block: 20px;
padding-block-start: 40px;
}
The block-start padding becomes 40 pixels, while the block-end padding remains 20 pixels.
Shorthand After Longhand
.box {
padding-block-start: 40px;
padding-block: 20px;
}
The later shorthand sets both block sides to 20 pixels, overriding the earlier block-start declaration at equal cascade priority.
Interaction With Physical Padding
.box {
writing-mode: horizontal-tb;
padding-top: 40px;
padding-block-start: 10px;
}
Both declarations target the top 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-start are relative to the containing block's logical width, not necessarily its physical width.
Horizontal Writing Mode
.container {
width: 400px;
}
.box {
padding-block-start: 5%;
}
If the containing block's logical width is 400 pixels, the block-start padding is 20 pixels.
Vertical Writing Mode
.container {
writing-mode: vertical-rl;
height: 300px;
}
.box {
padding-block-start: 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-start: clamp(1rem, 4vw, 3rem);
}
The padding adjusts with the viewport while remaining between 1rem and 3rem.
Combining Percentages and Lengths
.section {
padding-block-start: calc(5% + 10px);
}
The calculated value combines a percentage of the containing block's logical width with a fixed length.
padding-block-start Example
The following example demonstrates how logical block-start 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-start: 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-start padding appears above the content in horizontal writing mode, to its right in vertical-rl, and to its left in vertical-lr.
Practical Content Panel
.content-panel {
padding-block-start: 2rem;
padding-block-end: 1rem;
padding-inline: 1.5rem;
border: 1px solid #cbd5e1;
background-color: #f8fafc;
}
This creates additional space at the logical start of the block axis while maintaining consistent inline spacing.
Accessibility Considerations
The padding-block-start property can help maintain comfortable spacing around content in layouts that support different writing modes.
Provide Adequate Spacing
.notice {
padding-block-start: 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-start: 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-Start Always Means Top
Block-start corresponds to the top in horizontal writing modes, but it maps to the right or left side in vertical writing modes.
Confusing Block-Start With Inline-Start
padding-block-start follows the block axis, while padding-inline-start follows the inline axis. These properties can target different physical sides.
Using Negative Values
.box {
padding-block-start: -20px;
}
Negative padding values are invalid.
Using auto
.box {
padding-block-start: auto;
}
The auto keyword is not supported for padding.
Providing Multiple Values
.box {
padding-block-start: 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-start:
- It controls padding at the logical start of the block axis.
- Its physical side depends on the element's writing mode.
- In
horizontal-tb, it maps to top padding. - In
vertical-rl, it maps to right padding. - In
vertical-lr, it maps to left 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-start 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-top: 20px;
padding-block-start: 20px;
}
The physical declaration provides a fallback for horizontal writing modes when padding-block-start is unsupported.
For current compatibility information, visit Can I Use? and search for padding-block-start.
Specifications
The padding-block-start 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.
