CSS position

Demo

Copy

The CSS position property is used in positioning an element. It can be used in conjunction with the top, right, bottom, and left properties to position an element where you want it.

Also see the float property.

Syntax

position: <value>

Possible Values

static
The element flows as normal. The left and top properties don't take effect.
relative
The element is offset relative to it's normal position in the flow.
absolute
The element is positioned based on it's containing block. The element is taken out of the normal flow. Any subsequent elements will not be impacted
they will appear where they normally would even if the previous element was not offset.
fixed
Similar to absolute, but also doesn't move when scrolled.
inherit

Initial Value

static

Applies To

All elements except for generated content.

Inherited?

No

Media

Visual

Example Code

div {
  position: fixed;
  top: 20px;
  left: 50px;
  }