CSS bottom Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Positioning

What You’ll Learn

The bottom property offsets an element from the bottom edge of its containing block. It works with positioned elements to place boxes, footers, and overlays exactly where you need them.

01

Bottom Offset

Distance from bottom edge.

02

Needs position

relative, absolute, fixed.

03

px / em / rem

Length value units.

04

Percentages

Scale with container height.

05

auto Default

Browser-calculated position.

06

sticky Too

Works when element sticks.

Definition and Usage

The bottom CSS property sets the vertical offset of a positioned element from the bottom edge of its containing block. A positive value moves the element upward; the element sits that distance above the bottom edge.

Use bottom when you want to anchor UI near the lower edge of a container or the viewport — for example, a badge inside a card, a fixed footer bar, or an absolutely positioned overlay.

💡
Beginner Tip

bottom only works when position is relative, absolute, fixed, or sticky. Always set position first, then add bottom.

📝 Syntax

The syntax for bottom accepts length values, percentages, or the keyword auto:

syntax.css
selector {
  bottom: <length> | <percentage> | auto;
}

Basic Example

bottom.css
.box {
  position: absolute;
  bottom: 20px;
}

The value can be a length such as 20px, 1rem, or 2em, a percentage such as 10%, or auto to let the browser calculate placement.

Syntax Rules

  • The initial value is auto.
  • Requires a positioned element: relative, absolute, fixed, or sticky.
  • Length values use units like px, em, or rem.
  • Percentages are relative to the containing block’s height.
  • Pair with left, right, or top for full placement control.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toPositioned elements (relative, absolute, fixed, sticky)
InheritedNo
AnimatableYes, as a length or percentage
Common useFooters, overlays, badges, and anchored UI near the bottom edge

Default Value

The default value of bottom is auto. This means the element is not explicitly offset from the bottom unless you set a length or percentage.

With auto, the browser places the element using normal flow rules or other offset properties such as top.

💎 Property Values

The bottom property accepts length values, percentages, and the keyword auto.

ValueDescription
<length>Specifies the offset in units such as px, em, or rem. For example, bottom: 20px.
<percentage>Specifies the offset as a percentage of the containing block’s height. For example, bottom: 10%.
autoThe default value. The browser calculates the element’s bottom position.
initialSets the property to its default value
inheritInherits the property value from its parent element
20px 1rem 10% 0 auto

When bottom Works (position types)

bottom only affects elements that are taken out of normal static flow or offset within it. It works with these position values:

  • position: relative — shifts the element upward from its normal position by the bottom value.
  • position: absolute — places the element relative to its nearest positioned ancestor (or the initial containing block).
  • position: fixed — anchors the element relative to the viewport, useful for persistent footer bars.
  • position: sticky — applies bottom as a threshold when the element becomes stuck during scroll.
absolute — inside container
fixed — viewport footer
relative — nudged upward
sticky — stick threshold

bottom vs top vs inset-block-end

PropertyEdgeBest for
bottomPhysical bottom edgeFooters, bottom badges, and elements anchored near the lower edge in LTR layouts
topPhysical top edgeHeaders, top overlays, and elements anchored near the upper edge
inset-block-endLogical block-end edge (adapts to writing mode)Internationalized layouts where block direction may differ from physical bottom

👀 Live Preview

A blue box positioned 20px from the bottom of a relative container:

Uses position: absolute; and bottom: 20px; inside a position: relative container.

Examples Gallery

Try bottom with absolute positioning, fixed footers, relative offsets, and percentage values.

📚 Basic Positioning

Set position first, then use bottom to control vertical offset from the lower edge.

Example 1 — Box 20px from Bottom (Reference)

Position an absolutely positioned box 20 pixels from the bottom of a relative container.

bottom-reference.html
<style>
  .container {
    position: relative;
    height: 200px;
    border: 1px solid #000;
  }
  .box {
    position: absolute;
    bottom: 20px;
    width: 100px;
    height: 100px;
    background-color: blue;
  }
</style>

<h1>Box Positioned 20px from the Bottom</h1>
<div class="container">
  <div class="box"></div>
</div>
Try It Yourself

How It Works

The container establishes a positioning context with position: relative. The child box uses position: absolute and bottom: 20px to sit 20 pixels above the container’s bottom edge.

Example 2 — Fixed Footer Bar with bottom: 0

Pin a footer bar to the bottom of the viewport using position: fixed.

bottom-fixed-footer.html
<style>
  .footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    background: #1e293b;
    color: #fff;
    text-align: center;
    font-size: 0.875rem;
  }
</style>

<p>Scroll the page — the footer stays at the bottom.</p>
<div class="footer-bar">Fixed footer with bottom: 0</div>
Try It Yourself

How It Works

position: fixed removes the footer from document flow and anchors it to the viewport. bottom: 0 aligns its bottom edge flush with the viewport bottom.

📏 Relative and Percentage Offsets

Nudge elements with position: relative or scale placement with percentage-based bottom values.

Example 3 — Relative Positioning with Bottom Offset

Shift an element upward from its normal position using position: relative and bottom.

bottom-relative.html
<style>
  .offset-box {
    position: relative;
    bottom: 12px;
    padding: 0.75rem 1rem;
    background: #dbeafe;
    border: 1px solid #2563eb;
    max-width: 16rem;
  }
</style>

<p>Text above the offset box.</p>
<div class="offset-box">
  Nudged 12px upward with bottom.
</div>
<p>Text below — original space is preserved.</p>
Try It Yourself

How It Works

With position: relative, bottom: 12px moves the element 12 pixels upward from where it would normally sit, without removing it from document flow.

Example 4 — Percentage bottom: 10%

Place a box 10% of the container height above the bottom edge.

bottom-percentage.html
<style>
  .container {
    position: relative;
    height: 200px;
    border: 1px solid #64748b;
  }
  .box {
    position: absolute;
    bottom: 10%;
    left: 10%;
    width: 80px;
    height: 80px;
    background: #16a34a;
  }
</style>

<div class="container">
  <div class="box"></div>
</div>
Try It Yourself

How It Works

10% is calculated from the container’s height (200px), so the box sits 20px above the bottom edge. Percentages scale automatically when the container resizes.

🧠 How bottom Works

1

You set position

Choose relative, absolute, fixed, or sticky so bottom can take effect.

Position rule
2

You choose an offset

Set a length like 20px, a percentage like 10%, or leave auto.

Offset value
3

The browser measures from the bottom

The element is placed that distance above the bottom edge of its containing block or viewport.

Layout engine
=

Anchored placement

Your element sits at the vertical position you defined, anchored from the bottom edge.

Universal Browser Support

The bottom property is supported in all major browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is a standard CSS positioning property with excellent compatibility.

Baseline · All browsers

Reliable bottom positioning on every platform

Chrome, Firefox, Safari, Edge, and Opera all support bottom consistently.

100% Universal support
Google Chrome1+ · Desktop & Mobile
Full support
Mozilla Firefox1+ · Desktop & Mobile
Full support
Apple Safari1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera3.5+ · Modern versions
Full support
bottom property 100% supported

Bottom line: Use bottom freely in any project. It works consistently across all browsers.

Conclusion

The bottom property is a versatile tool for positioning elements vertically within a containing block or the viewport. Whether you are fine-tuning a single element or building fixed footers and overlays, understanding bottom helps you anchor UI near the lower edge with precision.

Experiment with length values like 20px, percentage values like 10%, and different position types to see how this property shapes your layouts.

💡 Best Practices

✅ Do

  • Set position before applying bottom
  • Use position: relative on parents when children use position: absolute
  • Use bottom: 0 with position: fixed for viewport footers
  • Combine bottom with left and right for full-width bars
  • Consider inset-block-end for logical layouts in multiple writing modes

❌ Don’t

  • Apply bottom to static elements and expect movement
  • Forget that relative offsets preserve the original layout space
  • Use fixed positioning without accounting for overlapping content
  • Mix top and bottom without understanding height constraints
  • Assume percentages work when the containing block has no defined height

Key Takeaways

Knowledge Unlocked

Five things to remember about bottom

Use these points when positioning elements from the lower edge.

5
Core concepts
⚙️02

Needs position

relative, absolute, fixed.

Requirement
📏03

px / % / auto

Length, percentage, default.

Values
📌04

Fixed Footers

bottom: 0 on viewport.

Pattern
🔄05

vs top

Opposite vertical anchor.

Compare

❓ Frequently Asked Questions

The bottom property sets how far an element is offset from the bottom edge of its containing block. It moves the element upward when you use a positive length or percentage.
The initial value is auto. With auto, the browser calculates the element's vertical position using normal layout or other positioning properties such as top.
No. bottom only affects elements whose position is relative, absolute, fixed, or sticky. On static elements it has no effect.
bottom measures distance from the bottom edge of the containing block, while top measures from the top. Use bottom when you want to anchor an element near the lower edge, such as a footer bar.
Use percentages when the offset should scale with the containing block's height. For example, bottom: 10% places the element 10% of the container height above the bottom edge.

Practice in the Live Editor

Open the HTML editor, try bottom, and preview vertical positioning instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful