Favorites

CSS <content-position> Data Type

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

The <content-position> data type is a keyword that places the content of a container as a group: start, end, center, flex-start or flex-end.

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 <content-position> CSS data type represents the keywords that place the content of a container as a group, for example pushing all the items to the start, the end or the centre. It is used by justify-content, align-content and place-content in flex, grid and (for align-content) block layout.

The keywords are center, start, end, flex-start and flex-end. start and end refer to the start and end of the container's writing mode, so they adapt to right-to-left and vertical text. flex-start and flex-end follow the direction of a flex container, which matters when flex-direction is reversed; outside flex layout they behave like start and end.

A <content-position> can be preceded by an <overflow-position> keyword, safe or unsafe, which controls what happens when the content is larger than the container. To share space between items instead of moving them together, use a <content-distribution> keyword.

Examples:

.center-all {
  display: grid;
  place-content: center;
}

.actions {
  display: flex;
  justify-content: end;
}

/* Centre, but never hide overflowing content */
.list {
  display: flex;
  flex-direction: column;
  justify-content: safe center;
}

Interactive Demo

One
Two
Three
Demo Code
HTML Code
<div class="demo-element">
	<div>One</div>
	<div>Two</div>
	<div>Three</div>
</div>
CSS Code
.demo-element > div {
	padding: 10px 12px;
	background: #4361ee;
	color: #fff;
	font-size: 14px;
	font-weight: bold;
}
.demo-element {
	display: grid;
	grid-auto-flow: column;
	width: 300px;
	gap: 6px;
	padding: 6px;
	box-sizing: border-box;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
	justify-content: start;
}

Syntax

<content-position> = center | start | end | flex-start | flex-end

Values

  • centerThe items are packed together in the centre of the container.
  • startThe items are packed toward the start edge of the container in its writing mode.
  • endThe items are packed toward the end edge of the container in its writing mode.
  • flex-startThe items are packed toward the main-start (or cross-start) side of a flex container. Outside flex layout it behaves like start.
  • flex-endThe items are packed toward the main-end (or cross-end) side of a flex container. Outside flex layout it behaves like end.

Example

<div class="wrap">
<h1>CSS &lt;content-position&gt; examples</h1>
<div class="grid">
<div class="card">
<div class="box start"><span></span><span></span><span></span></div>
<div class="label">justify-content: start</div>
</div>
<div class="card">
<div class="box center"><span></span><span></span><span></span></div>
<div class="label">justify-content: center</div>
</div>
<div class="card">
<div class="box end"><span></span><span></span><span></span></div>
<div class="label">justify-content: end</div>
</div>
<div class="card">
<div class="box rev"><span></span><span></span><span></span></div>
<div class="label">row-reverse with flex-start</div>
</div>
</div>
</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 {
  display: flex;
  gap: 6px;
  height: 110px;
  padding: 8px;
  border-radius: 10px;
  background: #e2e8f0;
}

.box span {
  width: 22px;
  border-radius: 6px;
  background: #2563eb;
}

.box span:nth-child(2) { height: 60%; }
.box span:nth-child(3) { height: 40%; }

.box span { height: 100% !important; }
.start { justify-content: start; }
.center { justify-content: center; }
.end { justify-content: end; }
.rev { flex-direction: row-reverse; justify-content: flex-start; }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS content-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.