CSS padding-bottom Property
The CSS padding-bottom property sets the space between an element's content and the bottom edge of its padding area.
It controls the physical bottom side of an element, regardless of writing mode or text direction. Padding creates internal spacing, contributes to the CSS box model, and normally displays the element's background color or image.
padding-bottom Syntax
The padding-bottom property accepts one non-negative length or percentage value, or a CSS-wide keyword.
Basic Syntax
selector {
padding-bottom: 20px;
}
This adds 20 pixels of internal spacing below the element's content.
Length Values
.box {
padding-bottom: 10px;
}
.box {
padding-bottom: 1.5rem;
}
.box {
padding-bottom: 2em;
}
.box {
padding-bottom: 3vh;
}
Lengths can use absolute units such as px or relative units such as rem, em, and viewport units.
Percentage Values
.box {
padding-bottom: 5%;
}
The percentage is calculated relative to the containing block's width, rather than its height.
Calculated Values
.box {
padding-bottom: calc(1rem + 10px);
}
.box {
padding-bottom: clamp(1rem, 4vw, 3rem);
}
CSS functions can combine units or constrain padding to a responsive range.
CSS-Wide Keywords
.box {
padding-bottom: initial;
}
.box {
padding-bottom: inherit;
}
.box {
padding-bottom: unset;
}
.box {
padding-bottom: revert;
}
.box {
padding-bottom: revert-layer;
}
CSS-wide keywords must be used alone and cannot be combined with length or percentage values.
Property Values
| Value | Description |
|---|---|
<length> |
Sets bottom padding using a non-negative length such as 10px, 1rem, or 2em. |
<percentage> |
Sets bottom padding as a non-negative percentage of the containing block's width. |
0 |
Removes bottom padding. |
initial |
Resets bottom padding to its initial value of 0. |
inherit |
Uses the computed bottom padding value from the parent element. |
unset |
Resets bottom padding to 0 because the property 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 width |
| Negative values | Not permitted |
| Physical side | Bottom |
| Shorthand | padding |
Valid Values
.box {
padding-bottom: 0;
}
.box {
padding-bottom: 20px;
}
.box {
padding-bottom: 1.5rem;
}
.box {
padding-bottom: 5%;
}
.box {
padding-bottom: calc(1rem + 5px);
}
Invalid Values
.box {
padding-bottom: -10px;
}
.box {
padding-bottom: auto;
}
.box {
padding-bottom: 10px 20px;
}
Negative values, auto, and multiple length or percentage values are invalid for this longhand property.
How It Works
The padding-bottom property creates space inside an element between its content box and the bottom border.
Increasing bottom padding expands the padding area. The effect on the element's overall size depends on its dimensions and box-sizing value.
Adding Bottom Padding
.panel {
padding-bottom: 30px;
background-color: #dbeafe;
border: 2px solid #2563eb;
}
The panel receives 30 pixels of internal spacing below its content.
Removing Bottom Padding
.panel {
padding-bottom: 0;
}
This removes bottom padding without changing padding on the other three sides.
Combining Individual Padding Properties
.panel {
padding-top: 10px;
padding-right: 20px;
padding-bottom: 30px;
padding-left: 20px;
}
Each physical side can have its own padding value.
Background and Padding
.notice {
padding-bottom: 20px;
background-color: #fef3c7;
border: 1px solid #d97706;
}
By default, the background extends through the padding area, so the additional bottom space shares the element's background.
Padding vs. Margin
Padding creates space inside an element's border. Margin creates space outside the border.
| Property | Effect |
|---|---|
padding-bottom |
Adds internal space below the content and above the bottom border. |
margin-bottom |
Adds external space below the element's border. |
Padding Example
.card {
padding-bottom: 30px;
background-color: #dbeafe;
}
The extra space appears inside the card and normally shares its background.
Margin Example
.card {
margin-bottom: 30px;
background-color: #dbeafe;
}
The extra space appears outside the card's border and does not receive the card's background.
Margin Collapsing
Vertical margins between certain block elements can collapse. Padding does not collapse, making it useful when a specific amount of internal spacing is required.
Padding and Box Sizing
The box-sizing property determines how declared dimensions account for padding and borders.
content-box
.box {
box-sizing: content-box;
height: 100px;
padding-bottom: 20px;
border: 2px solid #2563eb;
}
With content-box, the declared height applies to the content box. The bottom padding and borders increase the total rendered height to 124 pixels, assuming no other vertical padding.
border-box
.box {
box-sizing: border-box;
height: 100px;
padding-bottom: 20px;
border: 2px solid #2563eb;
}
With border-box, the 100-pixel height includes the content area, padding, and borders, provided the content fits.
Practical Use
.card {
box-sizing: border-box;
padding: 20px;
padding-bottom: 40px;
}
This gives the card extra bottom spacing while keeping its padding calculations predictable.
Percentage Padding
Percentage values for padding-bottom are calculated relative to the containing block's width, not its height.
Basic Percentage Example
.container {
width: 400px;
}
.box {
padding-bottom: 10%;
}
When the containing block is 400 pixels wide, 10% bottom padding equals 40 pixels.
Responsive Spacing
.section {
padding-bottom: 5%;
}
The bottom padding changes as the containing block's width changes.
Using calc()
.section {
padding-bottom: calc(5% + 10px);
}
The calculation combines a percentage-based value with a fixed amount of spacing.
Using clamp()
.section {
padding-bottom: clamp(1rem, 4vw, 3rem);
}
The padding adjusts with viewport width while remaining between 1rem and 3rem.
Important Consideration
Percentage padding depends on the containing block's size, so the same declaration can produce different results in different layouts.
Interaction With the padding Shorthand
The padding-bottom property is one of the four physical longhand properties controlled by the padding shorthand.
Using Four Values
.box {
padding: 10px 20px 30px 40px;
}
The values apply clockwise: top, right, bottom, and left. The bottom padding is 30 pixels.
Using Two Values
.box {
padding: 10px 20px;
}
The first value sets top and bottom padding to 10 pixels. The second sets right and left padding to 20 pixels.
Overriding Bottom Padding
.box {
padding: 20px;
padding-bottom: 40px;
}
The top, right, and left sides remain at 20 pixels, while the bottom becomes 40 pixels.
Shorthand After Longhand
.box {
padding-bottom: 40px;
padding: 20px;
}
At equal cascade priority, the later shorthand resets all four padding sides to 20 pixels.
Physical vs. Logical Padding
The padding-bottom property always targets the physical bottom side. Logical padding properties adapt to the writing mode.
| Property | Controls |
|---|---|
padding-bottom |
The physical bottom side in every writing mode. |
padding-block-end |
The logical block-end side, which is the bottom in horizontal-tb. |
padding-block-start |
The logical block-start side, which is the top in horizontal-tb. |
padding-inline-end |
The logical inline-end side, which can be the bottom in vertical writing modes. |
Physical Padding
.box {
writing-mode: vertical-rl;
padding-bottom: 30px;
}
The bottom side receives 30 pixels of padding, even though the writing mode is vertical.
Logical Padding
.box {
writing-mode: vertical-rl;
padding-block-end: 30px;
}
The left side receives 30 pixels of padding because it represents block-end in vertical-rl.
Choosing the Right Property
Use padding-bottom when the spacing must remain on the physical bottom. Use logical padding properties when spacing should follow the writing direction.
padding-bottom Example
The following example compares elements with no bottom padding, moderate bottom padding, and larger bottom padding.
HTML Example
<div class="padding-demo">
<div class="padding-card no-padding">
<strong>No Bottom Padding</strong>
<p>padding-bottom: 0;</p>
</div>
<div class="padding-card medium-padding">
<strong>20px Bottom Padding</strong>
<p>padding-bottom: 20px;</p>
</div>
<div class="padding-card large-padding">
<strong>40px Bottom Padding</strong>
<p>padding-bottom: 40px;</p>
</div>
</div>
CSS Example
.padding-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 15px;
}
.padding-card {
padding: 15px;
border: 2px solid #2563eb;
background-color: #dbeafe;
}
.padding-card p {
margin: 8px 0 0;
font-size: 14px;
}
.no-padding {
padding-bottom: 0;
}
.medium-padding {
padding-bottom: 20px;
}
.large-padding {
padding-bottom: 40px;
}
padding-bottom: 0;
padding-bottom: 20px;
padding-bottom: 40px;
The bottom padding increases the space between the paragraph and the bottom border. The background color extends through that space.
Practical Content Card
.content-card {
padding: 1.5rem;
padding-bottom: 2.5rem;
border: 1px solid #cbd5e1;
background-color: #f8fafc;
}
This creates extra space below the content while retaining consistent padding on the other three sides.
Accessibility Considerations
Bottom padding can help provide comfortable spacing between content and an element's border.
Improve Content Readability
.notice {
padding: 1rem;
padding-bottom: 1.5rem;
line-height: 1.5;
}
Additional internal spacing can prevent text from appearing crowded near the bottom edge of a notice or panel.
Support Text Resizing
Relative units such as rem allow padding to respond to user font-size settings.
Avoid Content Clipping
Large padding values combined with fixed heights and restrictive overflow settings may clip content. Test layouts at increased zoom levels and with longer text.
Maintain Usable Controls
Padding can contribute to the clickable area of buttons and other controls. Use sufficient spacing without relying on padding alone for accessibility.
Important Consideration
Padding improves layout spacing but does not replace semantic HTML, keyboard accessibility, readable typography, or sufficient contrast.
Common Mistakes
Confusing Padding With Margin
Padding creates space inside an element's border. Margin creates space outside it.
Using Negative Values
.box {
padding-bottom: -20px;
}
Negative padding is invalid. Use margins or positioning when a layout requires an offset.
Using auto
.box {
padding-bottom: auto;
}
The auto keyword is not supported for padding.
Assuming Percentages Use Element Height
.box {
padding-bottom: 10%;
}
The percentage is based on the containing block's width, not the element's height.
Forgetting Shorthand Overrides
.box {
padding-bottom: 40px;
padding: 20px;
}
At equal cascade priority, the later shorthand overrides the earlier bottom padding declaration.
Confusing Physical and Logical Padding
padding-bottom always targets the physical bottom side. Logical properties such as padding-block-end depend on writing mode.
Forgetting Box Sizing
Padding can increase the total rendered dimensions when box-sizing: content-box is used.
Important Considerations
Keep the following points in mind when using padding-bottom:
- It sets internal spacing on the physical bottom side.
- It does not change sides when writing mode or text direction changes.
- 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 width.
- It is a longhand property of the
paddingshorthand. - Later shorthand declarations can override its value.
- Padding creates space inside the element's border.
- Margins create space outside the border.
- Padding does not collapse like certain vertical margins.
- Background colors and images normally extend through the padding area.
- Padding contributes to the CSS box model.
- The
box-sizingproperty affects how padding contributes to declared dimensions. - Fixed dimensions combined with large padding can cause overflow.
- Relative units can support responsive spacing.
- Logical padding properties are available when spacing should follow writing mode.
Browser Support
The CSS padding-bottom property is Widely available and supported by all modern browsers, including Chrome, Edge, Firefox, and Safari.
It is a long-established CSS property with broad compatibility across desktop and mobile browsers.
For current compatibility information, visit Can I Use? and search for padding-bottom.
Specifications
The padding-bottom property is defined in CSS Box Model Module Level 3.
The specification defines padding properties, accepted values, and their contribution to the CSS box model.
For additional documentation and examples, consult MDN Web Docs.
