The padding-right property sets inner spacing on the right edge of an element. It controls spacing inside the box so content does not touch the right border directly.
The padding-right property in CSS is used to define the space between the content of an element and its right border.
This property allows you to control the inner spacing, enhancing the readability and visual appeal of your webpage by ensuring that the content does not touch the borders directly.
Definition and Usage
Apply padding-right when you need extra room to the right of the content inside an element — for example, making room beside a close icon, offsetting text in a toolbar, or adding space inside a card before the right border.
Like all padding properties, padding-right increases the visible size of an element’s background and border box. It never collapses and always stays inside the element’s border.
💡
Beginner Tip
Use padding-right for inner spacing on the right. Use margin-right when you need space outside the element, between this box and the one to its right.
padding-right → space after contentAlways the physical right edge
Foundation
📝 Syntax
The syntax for the padding-right property is straightforward. You can specify the padding using various units like pixels, ems, percentages, and more.
syntax.css
element{padding-right:value;}
Here, value can be a length, percentage, or the keyword auto.
Four boxes with the same content and different pr- utility classes showing increasing right inner spacing:
pr-sm
pr-md
pr-lg
pr-xl
Hands-On
Examples Gallery
Start with the reference box example, try different right values, add trailing spacing in components, and compare physical right padding with logical inline-end padding.
🔢 Basic padding-right
Start with the reference example — right padding on a div with a border and light gray background.
Example 1 — Box with Right Padding
In this example, we’ll add right padding of 20px to a <div> element.
padding-right-example.html
<style>.box{padding-right:20px;border:1px solid black;background-color:lightgray;}</style><divclass="box">
This box has 20px right padding.
</div>
The light gray background fills the padding area, so the 20px gap appears between the content and the right border. The padding stays inside the border.
Example 2 — Different Right Values
Use rem units for scalable right spacing that grows with root font size.
Each class sets a different right padding while leaving the left side unchanged. The background fills the padding area so you can compare the spacing visually.
🛠 Layout Patterns
Apply right padding to components and compare physical vs logical properties.
Example 3 — Alert Bar with Trailing Space
Add right padding so message text does not crowd a dismiss area on the right.
In horizontal LTR English, both approaches look the same. padding-inline-end stays correct when text direction changes to RTL; physical right padding does not.
Companion
padding-right vs padding, padding-inline-end & margin-right
The padding shorthand sets padding on all four sides at once. Use padding-right when you need spacing on only the right edge.
padding-inline-end is the logical equivalent that follows the inline axis. Use padding-right for simple physical layouts; prefer padding-inline-end in multilingual or RTL designs. Remember: margin-right adds space outside the border, not inside it.
padding-right-companion.css
/* Right only */.toolbar{padding-right:1.25rem;}/* All four sides via shorthand */.card{padding:1rem1.5rem;}/* Space to the right outside the border */.sidebar{margin-right:2rem;}
A11y
♿ Accessibility
Improve readability — Text benefits from right padding so content does not crowd the right border or trailing controls.
Touch targets — Buttons and dismiss icons need comfortable right padding so text does not overlap them.
RTL layouts — For multilingual sites, consider padding-inline-end instead of padding-right so spacing follows text direction.
Do not hide content — Very large right padding on small screens can squeeze readable text area.
Test zoomed layouts — Users who zoom in rely on comfortable padding to keep text readable.
🧠 How padding-right Works
1
You set a padding value
Write padding-right: 20px; with a length, percentage, or keyword.
CSS rule
2
Browser adds space on the right
Padding is inserted between the content edge and the border on the right side only.
Box model
3
Background fills the padding area
The element’s background color and background image extend into the padding box, making the gap visible.
Rendering
=
▦
Comfortable right spacing
Content has breathing room after it without affecting spacing on other sides or outside the border.
Compatibility
Browser Compatibility
The padding-right property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera, as well as older browsers. It is a well-established property in the CSS specification, so you can use it confidently across different web projects.
✓ Universal · All browsers
Right padding works everywhere
Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer all support padding-right as a core box-model property.
100%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Legacy & Chromium
Full support
OperaAll versions
Full support
padding-right property100% supported
Bottom line:padding-right is one of the most reliable CSS properties. Safe to use in any project without fallbacks.
Wrap Up
Conclusion
The padding-right property is an essential tool in CSS for managing the spacing within elements.
By controlling the right padding, you can create visually appealing layouts and improve the user experience on your website. Experiment with different values and units to see how they impact the appearance and readability of your content.
Use padding-right for inner spacing on the right in LTR layouts
Prefer rem or em for scalable right spacing
Pair with trailing icons or actions that need reserved space
Use the padding shorthand when all sides need spacing
Consider padding-inline-end for RTL-aware international layouts
❌ Don’t
Confuse padding-right with margin-right for outer spacing
Use excessive right padding that pushes content off small screens
Forget that percentage padding is based on width, not height
Rely on padding-right alone in RTL multilingual layouts
Use physical right padding when writing-mode-aware layouts need logical properties
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about padding-right
Use these points when spacing content on the right edge.
5
Core concepts
→01
Right Only
One physical edge.
Purpose
002
Default 0
No spacing.
Default
▦03
Inside Border
Part of box model.
Scope
%04
Units
px, em, rem, %.
Values
pie05
Not inline-end
Physical vs logical.
Companion
❓ Frequently Asked Questions
The padding-right property sets inner spacing on the right edge of an element, between the content and the right border. It creates horizontal room after the content inside the element.
The default value is 0, meaning no right inner spacing is applied unless you set padding-right explicitly.
padding-right adds space inside the element, between the content and the border. margin-right adds space outside the border, between this element and the element to its right.
padding-right always targets the physical right edge. padding-inline-end follows the inline axis and stays correct when text direction changes to RTL.
Yes. Percentage padding is calculated relative to the width of the containing block, even for right padding.