CSS bottom Property
The bottom property in CSS is used to specify the vertical position of an element relative to its nearest positioned ancestor (an ancestor with a position other than static). It works in conjunction with position: absolute, position: fixed, or position: relative to adjust the position of an element.
1. Syntax
| Value | Description |
|---|---|
length | Specifies a fixed distance (e.g., px, em, %, etc.) from the bottom of the element's containing block. |
% | Defines the distance relative to the height of the containing block. |
auto (default) | The browser automatically calculates the position of the element. |
2. How It Works
-
When you set an element's
positionto absolute, fixed, or relative, thebottomproperty allows you to define how far the element should be from the bottom edge of its containing block or viewport (forfixedpositioning). -
The element is positioned relative to the bottom edge when you specify a value for
bottom.
3. Example – Using bottom with position: absolute
✅ The <div> will be 20px above the bottom of its containing element.
4. Example – Using bottom with position: fixed
✅ The <div> will always be at the bottom of the browser window.
5. Example – Using bottom with position: relative
✅ The <div> is shifted 30px upward from its original position.
6. Best Practices
✔ Use bottom with position: absolute when you need to place an element at a specific distance from the bottom of its container.
✔ For fixed positioning, use bottom: 0 to pin elements (like footers) to the bottom of the viewport.
✔ Avoid using bottom with position: static, as it has no effect unless the position is set to something else.

