CSS padding-inline-start Property
The CSS padding-inline-start property sets the padding at the logical start of an element's inline axis.
The physical side receiving padding depends on the element's writing mode and text direction. It typically controls left padding in left-to-right layouts, right padding in right-to-left layouts, and top or bottom padding in vertical writing modes.
padding-inline-start Syntax
The padding-inline-start property accepts one non-negative length or percentage value, or a CSS-wide keyword.
Basic Syntax
selector {
padding-inline-start: 20px;
}
This adds 20 pixels of padding at the element's logical inline-start side.
Length Values
.box {
padding-inline-start: 10px;
}
.box {
padding-inline-start: 1.5rem;
}
.box {
padding-inline-start: 2em;
}
.box {
padding-inline-start: 3vw;
}
Lengths may use absolute or relative CSS units. Relative units can help spacing adapt to font sizes and viewport dimensions.
Percentage Values
.box {
padding-inline-start: 5%;
}
The percentage is calculated relative to the containing block's logical width.
Calculated Values
.box {
padding-inline-start: calc(1rem + 10px);
}
.box {
padding-inline-start: clamp(1rem, 3vw, 2.5rem);
}
CSS functions such as calc() and clamp() can create flexible padding values.
CSS-Wide Keywords
.box {
padding-inline-start: initial;
}
.box {
padding-inline-start: inherit;
}
.box {
padding-inline-start: unset;
}
.box {
padding-inline-start: revert;
}
.box {
padding-inline-start: revert-layer;
}
CSS-wide keywords must be used alone and 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 inline-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 CSS cascade origin rules. |
revert-layer |
Reverts the property according to CSS 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 | Inline axis |
| Shorthand | padding-inline |
Valid Values
.box {
padding-inline-start: 0;
}
.box {
padding-inline-start: 20px;
}
.box {
padding-inline-start: 1.5rem;
}
.box {
padding-inline-start: 5%;
}
.box {
padding-inline-start: calc(1rem + 5px);
}
Invalid Values
.box {
padding-inline-start: -10px;
}
.box {
padding-inline-start: auto;
}
.box {
padding-inline-start: 10px 20px;
}
Negative values, auto, and multiple length or percentage values are invalid for this longhand property.
How It Works
The padding-inline-start property creates internal spacing between an element's content and the border on its logical inline-start side.
Unlike padding-left or padding-right, it follows the direction of inline content rather than a fixed physical side.
Adding Inline-Start Padding
.panel {
padding-inline-start: 30px;
background-color: #dbeafe;
border: 2px solid #2563eb;
}
In a horizontal left-to-right writing mode, the panel receives 30 pixels of padding on its left side.
Removing Inline-Start Padding
.panel {
padding-inline-start: 0;
}
This removes padding from the logical inline-start side without changing padding on the other sides.
Combining Logical Padding Properties
.panel {
padding-inline-start: 30px;
padding-inline-end: 10px;
padding-block: 20px;
}
This applies 30 pixels at inline-start, 10 pixels at inline-end, and 20 pixels on both block sides.
Background and Padding
.notice {
padding-inline-start: 20px;
background-color: #fef3c7;
border: 1px solid #d97706;
}
By default, the element's background extends through its padding area, including the additional space at inline-start.
Writing Modes and Text Direction
The physical inline-start side depends on both writing-mode and direction.
| Writing Mode | Direction | Inline-Start Side |
|---|---|---|
horizontal-tb |
ltr |
Left |
horizontal-tb |
rtl |
Right |
vertical-rl |
ltr |
Top |
vertical-rl |
rtl |
Bottom |
vertical-lr |
ltr |
Top |
vertical-lr |
rtl |
Bottom |
sideways-rl |
ltr |
Top |
sideways-lr |
ltr |
Bottom |
Horizontal Left-to-Right
.box {
writing-mode: horizontal-tb;
direction: ltr;
padding-inline-start: 30px;
}
The left side receives 30 pixels of padding.
Horizontal Right-to-Left
.box {
writing-mode: horizontal-tb;
direction: rtl;
padding-inline-start: 30px;
}
The right side receives 30 pixels of padding.
Vertical Left-to-Right
.box {
writing-mode: vertical-rl;
direction: ltr;
padding-inline-start: 30px;
}
The top side receives 30 pixels of padding.
Vertical Right-to-Left
.box {
writing-mode: vertical-rl;
direction: rtl;
padding-inline-start: 30px;
}
The bottom side receives 30 pixels of padding.
Text Direction and Inline-Start
Changing direction can reverse inline-start and inline-end. This makes logical padding useful for layouts that support multiple text directions.
Physical vs. Logical Padding
Physical padding properties target fixed sides. Logical padding properties adapt to writing mode and text direction.
| Property | Controls |
|---|---|
padding-left |
Physical left side |
padding-right |
Physical right side |
padding-top |
Physical top side |
padding-bottom |
Physical bottom side |
padding-inline-start |
Logical inline-start side |
Physical Padding
.box {
padding-left: 30px;
}
The left side receives padding regardless of writing mode or text direction.
Logical Padding
.box {
padding-inline-start: 30px;
}
The padding moves to whichever physical side represents inline-start in the current writing mode and direction.
Why Use Logical Padding?
Logical padding reduces the need for separate layout rules when supporting left-to-right, right-to-left, and vertical writing.
It is particularly useful for reusable components, navigation, forms, and multilingual interfaces.
Interaction With padding-inline
The padding-inline-start property is one of the two longhand properties controlled by the padding-inline shorthand.
Using the Shorthand
.box {
padding-inline: 30px 10px;
}
This is equivalent to:
.box {
padding-inline-start: 30px;
padding-inline-end: 10px;
}
Overriding Inline-Start
.box {
padding-inline: 20px;
padding-inline-start: 40px;
}
The inline-start padding becomes 40 pixels, while the inline-end padding remains 20 pixels.
Shorthand After Longhand
.box {
padding-inline-start: 40px;
padding-inline: 20px;
}
At equal cascade priority, the later shorthand sets both inline sides to 20 pixels.
Interaction With Physical Padding
.box {
writing-mode: horizontal-tb;
direction: ltr;
padding-left: 40px;
padding-inline-start: 10px;
}
Both declarations target the left side in this writing mode and direction. At equal cascade priority, the later logical declaration takes effect.
When mixing physical and logical padding, consider writing mode, text direction, specificity, and declaration order.
Percentage Padding
Percentage values for padding-inline-start are calculated relative to the containing block's logical width.
Horizontal Writing Mode
.container {
width: 400px;
}
.box {
padding-inline-start: 5%;
}
If the containing block's logical width is 400 pixels, the inline-start padding is 20 pixels.
Vertical Writing Mode
.container {
writing-mode: vertical-rl;
height: 300px;
}
.box {
padding-inline-start: 10%;
}
In vertical writing modes, 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-inline-start: clamp(1rem, 4vw, 3rem);
}
The padding adjusts with viewport width while remaining between 1rem and 3rem.
Combining Percentages and Lengths
.section {
padding-inline-start: calc(5% + 10px);
}
The calculated value combines percentage-based spacing with a fixed length.
Important Consideration
Percentage padding depends on the containing block's logical width, so the resulting space may change when the writing mode or containing block dimensions change.
padding-inline-start Example
The following example demonstrates how padding-inline-start changes physical sides in left-to-right, right-to-left, and vertical writing modes.
HTML Example
<div class="inline-demo">
<div class="inline-item">
<h3>Left-to-Right</h3>
<div class="inline-box inline-ltr">
<span>Content</span>
</div>
</div>
<div class="inline-item">
<h3>Right-to-Left</h3>
<div class="inline-box inline-rtl">
<span>Content</span>
</div>
</div>
<div class="inline-item">
<h3>Vertical Writing</h3>
<div class="inline-box inline-vertical">
<span>Content</span>
</div>
</div>
</div>
CSS Example
.inline-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 20px;
padding: 20px;
background-color: #f1f5f9;
}
.inline-item h3 {
margin: 0 0 10px;
font-size: 16px;
}
.inline-box {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
min-height: 150px;
padding-inline-start: 40px;
padding-inline-end: 10px;
padding-block: 15px;
border: 2px solid #2563eb;
background-color: #bfdbfe;
}
.inline-box span {
padding: 8px;
background-color: #fff;
}
.inline-ltr {
writing-mode: horizontal-tb;
direction: ltr;
}
.inline-rtl {
writing-mode: horizontal-tb;
direction: rtl;
}
.inline-vertical {
writing-mode: vertical-rl;
direction: ltr;
}
Left-to-Right
Right-to-Left
Vertical Writing
The 40-pixel inline-start padding appears on the left in left-to-right horizontal writing, on the right in right-to-left horizontal writing, and at the top in vertical left-to-right writing.
Practical Content Panel
.content-panel {
padding-inline-start: 2rem;
padding-inline-end: 1rem;
padding-block: 1.5rem;
border: 1px solid #cbd5e1;
background-color: #f8fafc;
}
This provides additional space at inline-start while allowing the layout to adapt to different writing directions.
Accessibility Considerations
Logical padding can help maintain consistent spacing in multilingual interfaces and layouts that support different writing modes.
Support Multilingual Layouts
.content-panel {
padding-inline-start: 1.5rem;
padding-block: 1rem;
}
The padding follows the logical start of the inline axis when the layout changes between left-to-right, right-to-left, or vertical writing.
Support Text Resizing
Relative units such as rem can help spacing respond to user font-size preferences.
Avoid Content Clipping
Large padding values combined with fixed dimensions may reduce the available content area. Test layouts with enlarged text, long words, and narrow viewports.
Maintain Usable Controls
Padding can contribute to the clickable area of buttons and other interactive elements. Ensure controls remain usable with keyboard navigation and touch input.
Important Consideration
Padding supports readable layouts but does not replace semantic HTML, sufficient color contrast, or keyboard accessibility.
Common Mistakes
Assuming Inline-Start Always Means Left
Inline-start corresponds to the left in horizontal left-to-right layouts, but it can map to the right, top, or bottom in other writing modes and directions.
Ignoring Text Direction
In horizontal right-to-left layouts, inline-start is on the right rather than the left.
Confusing Inline-Start With Block-Start
padding-inline-start follows the inline axis, while padding-block-start follows the block axis.
Using Negative Values
.box {
padding-inline-start: -20px;
}
Negative padding values are invalid.
Using auto
.box {
padding-inline-start: auto;
}
The auto keyword is not supported for padding.
Providing Multiple Values
.box {
padding-inline-start: 10px 20px;
}
This longhand property accepts only one value. Use padding-inline to set both logical inline sides.
Mixing Physical and Logical Padding
Physical and logical declarations may target the same side. Their interaction depends on writing mode, text direction, and cascade priority.
Forgetting Box Sizing
Padding contributes to the element's dimensions. With box-sizing: content-box, it can increase the rendered size beyond a declared width or height.
Important Considerations
Keep the following points in mind when using padding-inline-start:
- It controls padding at the logical start of the inline axis.
- Its physical side depends on writing mode and text direction.
- In horizontal left-to-right layouts, it maps to left padding.
- In horizontal right-to-left layouts, it maps to right padding.
- In vertical left-to-right layouts, it maps to top padding.
- In vertical right-to-left layouts, it maps to bottom padding.
- 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-inline. - 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 the padding area.
- Padding contributes to the CSS box model.
- Padding does not collapse like certain vertical 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-inline-start property is Widely available in modern browsers, including current versions of Chrome, Edge, Firefox, and Safari.
It is part of CSS Logical Properties and Values. Older browsers may not support logical padding properties, so projects requiring legacy browser support should verify compatibility.
Physical Fallback Example
.box {
padding-left: 20px;
padding-inline-start: 20px;
}
The physical declaration provides fallback spacing for horizontal left-to-right writing modes when padding-inline-start is unsupported.
For current compatibility information, visit Can I Use? and search for padding-inline-start.
Specifications
The padding-inline-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 and text direction.
For additional documentation and examples, consult MDN Web Docs.
