Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Positioning and Stacking

The bottom property

Reference for the CSS bottom property: how it offsets positioned elements from the bottom edge, what percentages mean, and how it combines with top.

The bottom property sets the vertical offset of a positioned element from the bottom edge of its reference box. For an absolute element that is the padding edge of the nearest positioned ancestor, for fixed it is the viewport, and for sticky it is the bottom edge of the scrollport.

With position: static the property is ignored. A positive value moves the element's bottom edge up, away from the reference edge, which can feel backwards for relative elements: bottom: 10px shifts a relatively positioned box 10px upward.

CSS
.toast {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
}

Try it

Pinned to the bottom

Syntax

CSS
bottom: auto | <length> | <percentage> | <anchor()> | <anchor-size()>;
  • Initial value: auto
  • Applies to: positioned elements
  • Inherited: no
  • Percentages: refer to the height of the containing block
  • Animatable: yes, as a length or percentage
  • Computed value: for positioned elements, an absolute length or a percentage as specified; auto where it cannot be resolved; for static elements, auto

Values

Value Description
auto No offset. The edge is determined by top and the element's height, or by normal flow.
<length> A fixed distance from the bottom edge. Negative values push the element past the edge.
<percentage> A percentage of the containing block's height.
anchor(...) A position taken from an anchor element (see anchor positioning).

Usage notes

  • Bottom-anchored UI. bottom is the natural choice for toasts, cookie banners and floating buttons that must stay at the bottom as the box height changes.
  • Containing block height matters. For absolute elements, bottom counts from the bottom of the ancestor's padding box, so an ancestor that grows moves the element with it.
  • top plus bottom. With both set and height: auto, the element stretches between them (as in the third tag above). If height is also set, the offsets are over-constrained and top wins in horizontal left-to-right modes.
  • Mobile viewports. On phones, position: fixed; bottom: 0 can sit under the browser toolbar as it shows and hides. Test on real devices, or consider env(safe-area-inset-bottom) for notches.
  • Animate with transform rather than bottom when you want smooth motion; changing bottom forces layout.

Browser support

Supported in every browser for many years.