CSS bottom Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The bottom property sets the vertical inset from the bottom for a positioned element. It has no effect when position is static (the default).

With absolute or fixed, it is the gap between the element’s bottom margin edge and the containing block’s bottom. With relative, a positive value moves the element up from its normal position. Pair it with top, left, and right as needed.

Baseline · Widely available.

Not deprecated. Length, percentage, and auto are widely supported. anchor() / anchor-size() values are newer and still missing in some browsers.

CSS Syntax

syntax.css
bottom: auto | <length> | <percentage> | initial | inherit;

The initial value is auto. Percentages refer to the containing block’s height.

Property Values

ValueDescriptionTry it
autoDefault. Browser uses normal layout or topTry it
<length>Fixed offset such as 20px or 2emTry it
<percentage>Percent of the containing block’s heightTry it
relative usePositive bottom moves the box up from normal flowTry it
fixed useOffset from the viewport bottomTry it
initialResets to autoTry it
inheritInherits this property from the parent elementTry it

How to Use bottom

Position the element first, then set how far it sits from the bottom.

  1. Set position to relative, absolute, fixed, or sticky.
  2. For absolute, give a parent position: relative (or another positioned ancestor) so the containing block is clear.
  3. Set bottom to a length, percentage, or auto.
  4. Add left/right if you also need a horizontal inset.
PieceRequired?Role
Non-static positionYesWithout it, bottom does nothing
Containing blockFor absoluteUsually a relative parent with a height
Offset valueYesLength, percentage, or auto
topOptionalCan conflict; see edge cases

Live Preview

An absolutely positioned box sits inside a relative stage. Change bottom and watch the gap from the lower edge.

The stage is position: relative. The blue box is position: absolute.

Stage

bottom: 0

CSS Examples

Each snippet focuses on bottom with the minimum positioning needed to see it. Use Try It Yourself for a live editor.

Example 1 — Absolute Offset from Bottom

Pin a box 20px above the bottom of a relative container.

CSS
<style>
  .stage {
    position: relative;
    height: 160px;
    border: 1px solid #ccc;
  }
  .box {
    position: absolute;
    bottom: 20px;
    left: 16px;
    background: #2563eb;
    color: #fff;
    padding: 8px;
  }
</style>

<div class="stage">
  <div class="box">20px up</div>
</div>
Try It Yourself

How It Works

  1. Create a containing block. position: relative on the stage makes it the reference for absolute children.
  2. Take the box out of flow. position: absolute lets inset properties place it.
  3. Set the bottom gap. bottom: 20px puts 20px between the box’s bottom and the stage’s bottom.
  4. Add a horizontal inset. left: 16px only places it sideways; it is not required for bottom to work.

Example 2 — Relative Shift Up

A positive bottom on a relative element moves it upward.

CSS
<style>
  .box {
    position: relative;
    bottom: 24px;
    background: #2563eb;
    color: #fff;
    padding: 8px;
    display: inline-block;
  }
</style>

<p>Text before <span class="box">shifted up</span> text after.</p>
Try It Yourself

How It Works

  1. Stay in the document flow. position: relative keeps the original space in the line.
  2. Measure from the bottom. Positive bottom means “move the bottom edge up.”
  3. See the visual shift. The box appears 24px higher than where it would sit normally.
  4. Gap remains. The layout still reserves the unshifted spot, so neighbors do not close the hole.

Example 3 — Percentage of Container Height

Offset scales with the containing block’s height.

CSS
<style>
  .stage {
    position: relative;
    height: 160px;
    border: 1px solid #ccc;
  }
  .box {
    position: absolute;
    bottom: 25%;
    left: 16px;
    background: #2563eb;
    color: #fff;
    padding: 8px;
  }
</style>

<div class="stage">
  <div class="box">25%</div>
</div>
Try It Yourself

How It Works

  1. Give the stage a height. Percentages need a definite containing-block height.
  2. Use absolute positioning. The box is placed against that stage.
  3. Scale the gap. bottom: 25% is one quarter of 160px, so about 40px from the bottom.
  4. Resize the stage. If the height changes, the offset changes with it.

Edge Cases & Pitfalls

If the box does not move, one of these is usually why.

static

Static position ignores bottom

The default is position: static. Set position to relative, absolute, fixed, or sticky first.

top

top can win over bottom

On relative, or when height is constrained, top takes precedence and bottom is ignored. Clear one of them, or leave height auto for absolute stretch.

percent

Percentages need a definite height

If the containing block’s height is auto and depends only on content, bottom: 10% may resolve like auto. Give the container an explicit height.

relative

Positive bottom moves up

For position: relative, larger bottom values raise the element. That feels opposite to absolute layout until you remember it offsets the bottom edge.

fixed

Fixed uses the viewport

With position: fixed, bottom is measured from the viewport (or a transformed ancestor), not from a normal relative parent.

Browser Support

bottom is a browser CSS property for positioned layout. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

bottom

Length, percentage, and auto work in all modern browsers and Internet Explorer. Anchor-based values need recent browsers.

100% Core value support
Google Chrome All versions
Full support
Mozilla Firefox All versions
Full support
Apple Safari All versions
Full support
Microsoft Edge All versions
Full support
Opera All versions
Full support
Samsung Internet All versions
Full support
Internet Explorer All versions · Core values
Full support
bottom Widely supported

Bottom line: Safe everywhere for auto, lengths, and percentages. Treat anchor() as progressive enhancement. It is not a runtime API.

Key Takeaways

  • Role: vertical inset from the bottom for positioned elements.
  • Needs position: ignored on static elements.
  • Absolute vs relative: gap from container bottom, or shift up from normal flow.
  • Initial value: auto. Not inherited. Percentages use containing-block height.

One line: non-static position + bottom: 20px; = offset from the bottom edge of the right containing block.

Frequently Asked Questions

It sets the vertical inset from the bottom for a positioned element. With absolute or fixed, that is the gap from the containing block’s bottom. With relative, it moves the element up from its normal spot.
The initial value is auto. The browser then uses normal layout or the top property to decide the vertical position.
No. bottom only affects elements with position relative, absolute, fixed, or sticky. On static elements it has no effect.
bottom measures from the bottom edge. top measures from the top. If both are set on a relative element, or when height is constrained, top usually wins and bottom is ignored.
Percentages refer to the containing block’s height. Use them when the offset should scale with the container, such as bottom: 10%.
Length, percentage, and auto are Baseline Widely available and work in all modern browsers and Internet Explorer. Newer anchor() values need recent browsers. It is a browser CSS property, not a Node.js feature.

Next: box-decoration-break

Control how borders and backgrounds split across line breaks and fragments.

box-decoration-break tutorial →

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.

8 people found this page helpful