Skip to main content

Positioning with top, right, bottom, and left

Four properties move elements around: top, right, bottom and left.

They have an effect only on positioned elements, which means a position of relative, absolute, fixed or sticky.


Positioning Text On an Image

Wrap an image in a relative container, then give each text label an absolute position with offsets, and the text sits on top of the image.

Example

The labels sit at the four corners of the image (top-left, top-right, bottom-left, bottom-right) and at its center.

Prompt
An HTML page that positions text at different spots over an image using top/right/bottom/left. In an internal <style> block, make a relative container holding an image area (use a colored box as a stand-in image). Add absolutely-positioned white text labels at the top-left, top-right, bottom-left, bottom-right, and center, each placed with top/right/bottom/left offsets.
Output: complete HTML page

All CSS Positioning Properties

The positioning properties in brief:

  • bottom — places the bottom edge of a positioned box.
  • clip — cuts off part of an absolutely positioned element.
  • left — places the left edge of a positioned box.
  • position — chooses how an element is positioned.
  • right — places the right edge of a positioned box.
  • top — places the top edge of a positioned box.