Favorites

CSS <position> Data Type

<position>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <position> data type is a point in a box, written with keywords such as left, center or top, lengths and percentages, as used by background-position.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <position> CSS data type represents a point in a two-dimensional space, used to place an image or shape inside an element's box. It is written as one to four values made from the keywords left, center, right, top and bottom, and from <length> and <percentage> offsets. It is not the same as the position property, which chooses how an element is laid out (static, relative, absolute and so on).

The <position> type is used by properties such as background-position, object-position, mask-position, offset-position, perspective-origin and transform-origin, and after the keyword at in functions such as radial-gradient(), conic-gradient(), circle() and ellipse().

With a single value, the other axis defaults to center, so left means left center and 20% means 20% center. With two values, the first is normally horizontal and the second vertical, although two keywords can be given in either order (top left and left top are the same). With three or four values, each keyword is followed by an offset measured from that edge, so right 20px bottom 10px places the point 20px from the right and 10px from the bottom. Percentages are special: 25% 75% lines up the point 25% across the image with the point 25% across the container, which is why 0% aligns the left edges and 100% aligns the right edges.

Examples:

/* Keywords */
.hero { background-position: center top; }

/* Lengths and percentages */
.avatar { object-position: 50% 20%; }

/* Edge offsets: 20px from the right, 10px from the bottom */
.badge-bg { background-position: right 20px bottom 10px; }

/* In functions after "at" */
.spotlight {
  background: radial-gradient(circle at 30% 40%, #fff, #0f172a);
}

Interactive Demo

Demo Code
HTML Code
<div class="demo-element"></div>
CSS Code
.demo-element {
	width: 280px;
	height: 170px;
	border-radius: 8px;
	background: #e7ecff url(/css-properties/images/sun.png) no-repeat;
	background-size: 60px;
	outline: 2px solid #4361ee;
	background-position: left top;
}

Syntax

<position> = [
  [ left | center | right ] || [ top | center | bottom ]
|
  [ left | center | right | <length-percentage> ]
  [ top | center | bottom | <length-percentage> ]?
|
  [ [ left | right ] <length-percentage> ] &&
  [ [ top | bottom ] <length-percentage> ]
]

Values

  • leftIs equivalent to a horizontal position of 0%.
  • rightIs equivalent to a horizontal position of 100%.
  • topIs equivalent to a vertical position of 0%.
  • bottomIs equivalent to a vertical position of 100%.
  • centerIs equivalent to position of 50% in the applicable direction.
  • <length-percentage>An offset from the left (horizontal) or top (vertical) edge, or, when it follows a keyword, from that edge. Percentages align the same point of the item and the container.

Example

<div class="wrap">
<h1>CSS &lt;position&gt; examples</h1>
<div class="grid">
<div class="card">
<div class="box p1"></div>
<div class="label">center</div>
</div>
<div class="card">
<div class="box p2"></div>
<div class="label">left top</div>
</div>
<div class="card">
<div class="box p3"></div>
<div class="label">right 20px bottom 10px</div>
</div>
<div class="card">
<div class="box p4"></div>
<div class="label">25% 75%</div>
</div>
<div class="card">
<div class="box p5"></div>
<div class="label">bottom (same as center bottom)</div>
</div>
<div class="card">
<div class="spot"></div>
<div class="label">radial-gradient(circle at 30% 40%, ...)</div>
</div>
</div>
<p class="note">Each box uses background-position with a different &lt;position&gt; value.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f5f7fb;
  color: #102a43;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  color: #486581;
  margin-top: 10px;
  word-break: break-word;
}

.note {
  font-size: 13px;
  color: #486581;
  margin-top: 14px;
}

/*  examples */
.box {
  height: 150px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background-color: #eff6ff;
  /* a small marker image so the position is easy to see */
  background-image: radial-gradient(circle, #2563eb 0 14px, transparent 15px);
  background-size: 32px 32px;
  background-repeat: no-repeat;
}

.p1 { background-position: center; }
.p2 { background-position: left top; }
.p3 { background-position: right 20px bottom 10px; }
.p4 { background-position: 25% 75%; }
.p5 { background-position: bottom; }

.spot {
  height: 150px;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 40%, #fde047, #0f172a 70%);
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS position data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.