Position
The
position
property specifies the type of positioning method used for an element.Common values:
static
: Default value; element is not positioned, and it is rendered in the normal flow.relative
: Positioned relative to its normal position.absolute
: Positioned relative to the nearest positioned ancestor.fixed
: Positioned relative to the browser window, and doesn't move when the page is scrolled.sticky
: Toggles betweenrelative
andfixed
, based on the user's scroll position.
Position Values You can also adjust individual position offsets using the following controls. These appear once you select a position value other than 'static'

Positioning can alter element stacking, affecting the rendering order.
Influences the offset properties:
top
,right
,bottom
, andleft
.Important for layout design, providing control over element placement.
Possible Values (for offset)
Any Number
px
Specifies the offset in pixels.
Any Number
%
Specifies the offset as a percentage of the containing block.
Any Number
rem
Specifies the offset relative to the font size of the root element.
Any Number
vw
Specifies the offset as a percentage of the viewport's width.
Any Number
vh
Specifies the offset as a percentage of the viewport's height.
N/A
auto
The browser calculates the offset automatically.
N/A
unset
Resets the property to its natural value or inherits from parent. It is like undoing the position.
Examples
Let's demonstrate positioning with an example: a parent container and its child container. We set the parent container's position to relative, and the child's to absolute, with
top: 35%
andleft: 30%



Last updated