HTML & CSS Interview Question #80
What does the CSS position property do?
CSS Layout, Display, Positioning, Flexbox & Grid Mid-Level Intermediate
Quick Interview Answer
The position property controls how an element is positioned and whether offset properties such as top, right, bottom, left, or logical inset properties affect it. Common values are static, relative, absolute, fixed, and sticky.
Detailed Explanation
The position property controls how an element is positioned and whether offset properties such as top, right, bottom, left, or logical inset properties affect it. Common values are static, relative, absolute, fixed, and sticky.
Positioning should be selected according to the desired containing block and scrolling behavior. It is not normally a replacement for Flexbox or Grid when the requirement is general page layout.
Code Example
.normal { position: static; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }