Tillitsdone
down Scroll to discover

CSS padding-bottom Enhance Your Web Design Layout

CSS padding-bottom sets the space between an element's content and its bottom border.

Use pixels, percentages, or global values like inherit and initial for precise control.
thumbnail

Introduction

In web development and design, the padding-bottom CSS property is essential for controlling the layout and aesthetics of web pages. This property sets the height of the padding area at the bottom of an element, creating space between the element’s content and its border. By effectively using padding-bottom, you can significantly enhance the visual appeal and readability of your web designs.

Specification

The padding-bottom property is defined in the CSS Box Model Module Level 3, under the “padding-physical” section. This specification outlines how the padding properties should be implemented and used in web development.

Syntax

The padding-bottom property in CSS is straightforward to use. It allows you to specify the height of the padding area at the bottom of an element. Here’s the basic syntax:

padding-bottom: value;

Supported Values

The padding-bottom property can accept several types of values:

  1. Length Values: Such as pixels (px), ems (em), centimeters (cm), etc.
    padding-bottom: 10px;
    padding-bottom: 2em;
    padding-bottom: 1cm;
  2. Percentage Values: Relative to the width of the containing block.
    padding-bottom: 10%;
  3. Global Values: Such as inherit, initial, revert, revert-layer, and unset.
    padding-bottom: inherit;
    padding-bottom: initial;
    padding-bottom: revert;
    padding-bottom: revert-layer;
    padding-bottom: unset;

Rules and Constraints

  • Non-negative Values: Padding values must be non-negative.
  • Default Value: The default value for padding-bottom is 0.

Example Syntax

Here’s an example of how to use the padding-bottom property in your CSS:

.content {
padding-bottom: 20px;
}
.sidebox {
padding-bottom: 5%;
}

Examples

To better understand how the padding-bottom property works, let’s explore some practical examples.

Example 1: Setting Padding Bottom with Pixels

In this example, we’ll use a fixed length value (pixels) to set the padding-bottom property.

HTML:

<!DOCTYPE html>
<html>
<head>
<title>CSS padding-bottom Property</title>
<style>
.content {
padding-bottom: 35px;
color: white;
background: green;
}
</style>
</head>
<body style="text-align: center;">
<h1 style="color: green;">Website</h1>
<h2>padding-bottom Property</h2>
<p class="content">
This paragraph has a padding-bottom of 35px.
</p>
</body>
</html>

Output: This paragraph has a padding-bottom of 35px.

Example 2: Setting Padding Bottom with Percentages

In this example, we’ll use a percentage value to set the padding-bottom property.

HTML:

<!DOCTYPE html>
<html>
<head>
<title>CSS padding-bottom Property</title>
<style>
.content {
padding-bottom: 10%;
color: white;
background: green;
}
</style>
</head>
<body style="text-align: center;">
<h1 style="color: green;">Website</h1>
<h2>padding-bottom Property</h2>
<p class="content">
This paragraph has a padding-bottom of 10%.
</p>
</body>
</html>

Output: This paragraph has a padding-bottom of 10%.

Example 3: Using Global Values

In this example, we’ll demonstrate how to use global values like inherit and initial to set the padding-bottom property.

HTML:

<!DOCTYPE html>
<html>
<head>
<title>CSS padding-bottom Property</title>
<style>
.parent {
padding-bottom: 20px;
}
.child {
padding-bottom: inherit;
color: white;
background: green;
}
.reset {
padding-bottom: initial;
color: white;
background: blue;
}
</style>
</head>
<body style="text-align: center;">
<h1 style="color: green;">Website</h1>
<h2>padding-bottom Property</h2>
<div class="parent">
<p class="child">
This paragraph inherits a padding-bottom of 20px from its parent.
</p>
<p class="reset">
This paragraph resets the padding-bottom to its initial value (0).
</p>
</div>
</body>
</html>

Output: This paragraph inherits a padding-bottom of 20px from its parent. This paragraph resets the padding-bottom to its initial value (0).

Browser Compatibility

The padding-bottom property is widely supported across all major web browsers, ensuring that your web designs remain consistent and functional regardless of the platform or device used by your visitors.

Supported Browsers

  • Google Chrome: Supported since version 1.0.
  • Microsoft Edge: Supported since version 12.0.
  • Internet Explorer: Supported since version 4.0.
  • Mozilla Firefox: Supported since version 1.0.
  • Opera: Supported since version 3.5.
  • Apple Safari: Supported since version 1.0.

Compatibility Table

BrowserMinimum Version
Google Chrome1.0
Microsoft Edge12.0
Internet Explorer4.0
Mozilla Firefox1.0
Opera3.5
Apple Safari1.0

Notes on Compatibility

  • Cross-Browser Consistency: The padding-bottom property behaves consistently across all supported browsers.
  • Legacy Support: The widespread support for padding-bottom means that even older browsers can correctly render your web pages.
  • Future-Proofing: Given its long-standing support, the padding-bottom property is a reliable choice for both current and future web development projects.

FAQs

What is the padding-bottom property in CSS?

The padding-bottom property in CSS sets the amount of space between the content of an element and its bottom edge. It adds extra space inside the element, increasing the distance between the content and the element’s border.

How can I set a 20px padding at the bottom of an element?

To set a 20px padding at the bottom of an element, use the following CSS:

padding-bottom: 20px;

Does padding-bottom affect the width of an element?

No, padding-bottom does not affect the width of an element. It only impacts the vertical space inside the element at the bottom edge.

How does padding-bottom interact with margin-bottom?

The padding-bottom property adds space inside the element, while the margin-bottom property adds space outside the element. They can be used together to control both internal and external spacing of an element.

Can padding-bottom be set in percentages?

Yes, you can set padding-bottom in percentages. The percentage is based on the width of the containing block, not the height. For example:

padding-bottom: 10%;

What are the global values for padding-bottom?

The global values for padding-bottom include:

  • inherit: Takes the value from the parent element.
  • initial: Resets to the default value (0).
  • revert: Resets to the browser’s default value.
  • revert-layer: Resets considering CSS cascade layers.
  • unset: Resets to the natural value, either initial or inherit.

Can negative values be used for padding-bottom?

No, you cannot use negative values for padding-bottom. It must be non-negative.

What is the default value for padding-bottom?

The default value for padding-bottom is 0.

icons/css-4.svg CSS Blogs
CSS3 is the latest version of Cascading Style Sheets, offering advanced styling features like animations, transitions, shadows, gradients, and responsive design.
css_property_cover/css-property-anchor-name.png CSS Anchor-Name Enhancing Web Layouts with Anchors Discover the CSS anchor-name property, a powerful tool for defining elements as anchors and creating dynamic, responsive web layouts. Learn about its use cases, available options, and how to effectively implement it in your projects. css_property_cover/css-property-font-variant-position.png CSS Font-Variant-Position Enhance Typography with Superscript and Subscript Discover the CSS font-variant-position property for controlling superscript and subscript glyphs. Learn about its use cases, available options like 'normal', 'sub', and 'super', and how to incorporate it into your web design projects for improved typography. css_property_cover/css-property-inset.png CSS Inset Simplify Element Positioning Learn how to use the CSS inset property to easily set the top, right, bottom, and left offsets of an element. Discover available options, examples, and browser compatibility. css_property_cover/css-property-inset-inline.png CSS Inset-Inline Master Element Positioning Discover the CSS inset-inline property for precise control over element positioning in the inline direction. Learn about available options, practical examples, and browser compatibility. css_property_cover/css-property-overflow-y.png CSS Overflow-y Managing Vertical Content Overflow Discover the CSS overflow-y property for managing vertical content overflow. Learn about its use cases, available options like visible, hidden, scroll, auto, and clip, and how to implement them effectively. css_property_cover/css-property-border-inline-width.png CSS border-inline-width Manage Logical Border Widths CSS border-inline-width lets you manage the width of logical inline borders for flexible and responsive designs. Use length values, keywords, and global values.
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.