CSS padding-inline-end Property

The CSS padding-inline-end property sets the padding at the logical end of an element's inline axis.

Unlike physical padding properties, padding-inline-end adapts to the element's writing mode and text direction. It can control padding on the right, left, top, or bottom side, depending on how the content flows.

padding-inline-end Syntax

The padding-inline-end property accepts one non-negative length or percentage value, or a CSS-wide keyword.

Basic Syntax

selector {
  padding-inline-end: 20px;
}

This adds 20 pixels of padding at the element's logical inline-end side.

Length Values

.box {
  padding-inline-end: 10px;
}
.box {
  padding-inline-end: 1.5rem;
}
.box {
  padding-inline-end: 2em;
}
.box {
  padding-inline-end: 3vw;
}

Length values may use absolute or relative CSS units. Relative units can help spacing adapt to font sizes and viewport dimensions.

Percentage Values

.box {
  padding-inline-end: 5%;
}

The percentage is calculated relative to the containing block's logical width.

Calculated Values

.box {
  padding-inline-end: calc(1rem + 10px);
}
.box {
  padding-inline-end: clamp(1rem, 3vw, 2.5rem);
}

CSS functions such as calc() and clamp() can create flexible padding values.

CSS-Wide Keywords

.box {
  padding-inline-end: initial;
}
.box {
  padding-inline-end: inherit;
}
.box {
  padding-inline-end: unset;
}
.box {
  padding-inline-end: revert;
}
.box {
  padding-inline-end: 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 inline-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 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-end: 0;
}
.box {
  padding-inline-end: 20px;
}
.box {
  padding-inline-end: 1.5rem;
}
.box {
  padding-inline-end: 5%;
}
.box {
  padding-inline-end: calc(1rem + 5px);
}

Invalid Values

.box {
  padding-inline-end: -10px;
}
.box {
  padding-inline-end: auto;
}
.box {
  padding-inline-end: 10px 20px;
}

Negative values, auto, and multiple length or percentage values are invalid for this longhand property.

How It Works

The padding-inline-end property creates internal spacing between an element's content and the border on its logical inline-end side.

The physical side represented by inline-end depends on the element's writing mode and text direction.

Adding Inline-End Padding

.panel {
  padding-inline-end: 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 right side.

Removing Inline-End Padding

.panel {
  padding-inline-end: 0;
}

The logical inline-end padding is removed without changing padding on the other sides.

Combining Logical Padding Properties

.panel {
  padding-inline-start: 10px;
  padding-inline-end: 30px;
  padding-block: 20px;
}

This applies 10 pixels at inline-start, 30 pixels at inline-end, and 20 pixels on both block sides.

Background and Padding

.notice {
  padding-inline-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 Text Direction

The inline-end side depends on both writing-mode and direction. Changing either property can change the physical side receiving padding.

Writing Mode Direction Inline-End Side
horizontal-tb ltr Right
horizontal-tb rtl Left
vertical-rl ltr Bottom
vertical-rl rtl Top
vertical-lr ltr Bottom
vertical-lr rtl Top

Horizontal Left-to-Right

.box {
  writing-mode: horizontal-tb;
  direction: ltr;
  padding-inline-end: 30px;
}

The right side receives 30 pixels of padding.

Horizontal Right-to-Left

.box {
  writing-mode: horizontal-tb;
  direction: rtl;
  padding-inline-end: 30px;
}

The left side receives 30 pixels of padding.

Vertical Left-to-Right

.box {
  writing-mode: vertical-rl;
  direction: ltr;
  padding-inline-end: 30px;
}

The bottom side receives 30 pixels of padding.

Vertical Right-to-Left

.box {
  writing-mode: vertical-rl;
  direction: rtl;
  padding-inline-end: 30px;
}

The top side receives 30 pixels of padding.

Important Difference

Unlike padding-block-end, which follows the block axis, padding-inline-end can change sides when text direction changes.

Physical vs. Logical Padding

Physical padding properties always target a fixed side. Logical padding properties adapt to the writing mode and text direction.

Property Controls
padding-right Physical right side
padding-left Physical left side
padding-top Physical top side
padding-bottom Physical bottom side
padding-inline-end Logical inline-end side

Physical Padding

.box {
  padding-right: 30px;
}

The right side receives padding regardless of writing mode or text direction.

Logical Padding

.box {
  padding-inline-end: 30px;
}

The padding moves to the physical side representing inline-end in the current writing mode and direction.

Why Use Logical Padding?

Logical padding is useful for multilingual websites and reusable components that support left-to-right, right-to-left, or vertical writing.

Instead of writing separate physical padding declarations for each direction, one logical declaration can adapt automatically.

Interaction With padding-inline

The padding-inline-end property is one of the two longhand properties controlled by the padding-inline shorthand.

Using the Shorthand

.box {
  padding-inline: 10px 30px;
}

This is equivalent to:

.box {
  padding-inline-start: 10px;
  padding-inline-end: 30px;
}

Overriding the Inline-End Side

.box {
  padding-inline: 20px;
  padding-inline-end: 40px;
}

The inline-start padding remains 20 pixels, while the inline-end padding becomes 40 pixels.

Shorthand After Longhand

.box {
  padding-inline-end: 40px;
  padding-inline: 20px;
}

The later shorthand sets both inline sides to 20 pixels, overriding the earlier inline-end declaration at equal cascade priority.

Interaction With Physical Padding

.box {
  writing-mode: horizontal-tb;
  direction: ltr;
  padding-right: 40px;
  padding-inline-end: 10px;
}

Both declarations target the right side in this writing mode and direction. At equal cascade priority, the later declaration takes effect.

When combining logical and physical padding, consider the writing mode, text direction, and CSS cascade.

Percentage Padding

Percentage values for padding-inline-end are calculated relative to the containing block's logical width.

Horizontal Writing Mode

.container {
  width: 400px;
}
.box {
  padding-inline-end: 5%;
}

If the containing block's logical width is 400 pixels, the inline-end padding is 20 pixels.

Vertical Writing Mode

.container {
  writing-mode: vertical-rl;
  height: 300px;
}
.box {
  padding-inline-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-inline-end: clamp(1rem, 4vw, 3rem);
}

The padding adjusts with viewport width while remaining between 1rem and 3rem.

Combining Percentages and Lengths

.section {
  padding-inline-end: calc(5% + 10px);
}

The calculated value combines a percentage of the containing block's logical width with a fixed length.

padding-inline-end Example

The following example demonstrates how padding-inline-end moves to different 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-end: 40px;
  padding-inline-start: 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;
}
Browser Result

Left-to-Right

Content

Right-to-Left

Content

Vertical Writing

Content

The 40-pixel inline-end padding appears on the right in left-to-right horizontal writing, on the left in right-to-left horizontal writing, and at the bottom in vertical left-to-right writing.

Practical Content Panel

.content-panel {
  padding-inline-start: 1rem;
  padding-inline-end: 2rem;
  padding-block: 1.5rem;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
}

This provides additional spacing at the logical inline-end side without requiring separate rules for left-to-right and right-to-left layouts.

Accessibility Considerations

Logical padding can help maintain comfortable spacing in interfaces that support different writing modes and text directions.

Support Multilingual Layouts

.content-panel {
  padding-inline-end: 1.5rem;
  padding-block: 1rem;
}

The padding follows the logical end 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 allow padding to respond to user font-size preferences.

Avoid Content Clipping

Large padding values combined with fixed dimensions can 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-End Always Means Right

Inline-end corresponds to the right in horizontal left-to-right layouts, but it can map to the left, top, or bottom in other writing modes and directions.

Ignoring Text Direction

In horizontal right-to-left layouts, inline-end is on the left rather than the right.

Confusing Inline-End With Block-End

padding-inline-end follows the inline axis, while padding-block-end follows the block axis.

Using Negative Values

.box {
  padding-inline-end: -20px;
}

Negative padding values are invalid.

Using auto

.box {
  padding-inline-end: auto;
}

The auto keyword is not supported for padding.

Providing Multiple Values

.box {
  padding-inline-end: 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-end:

  • It controls padding at the logical end of the inline axis.
  • Its physical side depends on writing mode and text direction.
  • In horizontal left-to-right layouts, it maps to right padding.
  • In horizontal right-to-left layouts, it maps to left padding.
  • In vertical left-to-right layouts, it maps to bottom padding.
  • In vertical right-to-left layouts, it maps to top padding.
  • It accepts one non-negative length or percentage value.
  • Negative values are invalid.
  • The auto keyword 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-end 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-right: 20px;
  padding-inline-end: 20px;
}

The physical declaration provides fallback spacing for horizontal left-to-right writing modes when padding-inline-end is unsupported.

For current compatibility information, visit Can I Use? and search for padding-inline-end.

Specifications

The padding-inline-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 and text direction.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: padding-inline-end