CSS right property

CSS right

CSS right property is used to specify the horizontal position of an element.

Depending on the parent container, CSS right property works differently,

  • If the position is absolute or fixed, the right property denotes the space between the containers right end and the elements right end.
  • If the position is relative, the right property denotes that the element is moved to the left side from the given position.
  • If the position is sticky, and if the element is inside the container it acts similar to relative, else if it is outside the container it works similar to the fixed.
  • If the position is static, the right property has no effect on the element.

Example 1 - right value while position is absolute

Try Yourself

Example 2 - right value while position is relative

Try Yourself

Example 3 - right value while position is sticky

Try Yourself