CSS Data Type
Description
The <position> CSS data type defines how an element is positioned in the document. It controls whether an element is placed in the normal flow of the document, anchored relative to its parent, or fixed with respect to the viewport. Understanding <position> is crucial for designing layouts, creating dynamic interfaces, and controlling how elements interact with each other on a page. The behavior of positioned elements often interacts with properties such as top, right, bottom, and left, which allow precise control over an element's placement when it is removed from the normal flow.
There are several key values for <position>:
- static: The default positioning where elements follow the normal flow of the document. Static elements do not respond to the
top,right,bottom, orleftproperties. - relative: Positions the element relative to its normal location. Using
top,right,bottom, orleftoffsets the element from where it would normally be placed. - absolute: Removes the element from the normal document flow and positions it relative to its closest positioned ancestor (an element whose
is notstatic). - fixed: Positions the element relative to the viewport, so it stays in the same place even when the page is scrolled.
- sticky: Acts like a hybrid of
relativeandfixed. The element is relative until it crosses a threshold defined by scroll position, after which it behaves likefixed.
For example:
/* Example of different <position> values */
.static-box {
position: static;
background-color: lightblue;
}
.relative-box {
position: relative;
top: 20px;
left: 20px;
background-color: lightgreen;
}
.absolute-box {
position: absolute;
top: 50px;
left: 50px;
background-color: lightcoral;
}
.fixed-box {
position: fixed;
bottom: 10px;
right: 10px;
background-color: lightgoldenrodyellow;
}
.sticky-box {
position: sticky;
top: 0;
background-color: lightpink;
}
<div class="static-box">Static Box</div>
<div class="relative-box">Relative Box</div>
<div class="absolute-box">Absolute Box</div>
<div class="fixed-box">Fixed Box</div>
<div class="sticky-box">Sticky Box</div>
The <position> type allows developers to create complex layouts such as overlapping elements, sticky headers, floating menus, and tooltips. It is also frequently combined with the <display> type to control both the box model behavior and flow of elements, offering extensive flexibility in modern CSS design.
Syntax
<position> = [ [ left | center | right ] || [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]
Values
- leftIs equivalent to a horizontal position of 0%.
- rightIs equivalent to a horizontal position of 100%.
- topIs equivalent to a vertical position of 0%.
- bottomIs equivalent to a vertical position of 100%.
- centerIs equivalent to position of 50% in the applicable direction.
Example
Browser Support
The following information will show you the current browser support for the CSS position data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.
This data type is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 3rd January 2026
