CSS place-self Property

The CSS place-self property is a shorthand for align-self and justify-self, allowing an individual item to control its alignment along both axes.

It is especially useful in CSS Grid layouts when one item needs different alignment from the defaults established by its container. You can center an item, position it at the start or end of its grid area, or stretch it along one or both axes.

place-self Syntax

The place-self property accepts one or two alignment values. The first sets align-self, while the second sets justify-self.

Basic Syntax

selector {
  place-self: center;
}

This is equivalent to setting both align-self and justify-self to center.

Two-Value Syntax

selector {
  place-self: start end;
}

In Grid, the first value controls the item's block-axis alignment. The second controls its inline-axis alignment.

Common Values

.grid-item {
  place-self: auto;
}
.grid-item {
  place-self: center;
}
.grid-item {
  place-self: start;
}
.grid-item {
  place-self: end center;
}
.grid-item {
  place-self: stretch;
}
.grid-item {
  place-self: center start;
}

Safe Alignment

.grid-item {
  place-self: safe center;
}
.grid-item {
  place-self: safe center safe end;
}

The safe keyword modifies supported positional alignment values to help prevent overflow-related data loss.

CSS-Wide Keywords

.grid-item {
  place-self: initial;
}
.grid-item {
  place-self: inherit;
}
.grid-item {
  place-self: unset;
}
.grid-item {
  place-self: revert;
}
.grid-item {
  place-self: revert-layer;
}

CSS-wide keywords must be used individually and cannot be combined with alignment values.

Property Values

The shorthand accepts values supported by its two longhand properties. Some values are meaningful only in particular alignment contexts.

Value Description
auto Uses the applicable alignment behavior established by the parent container.
normal Uses the normal self-alignment behavior for the layout context.
start Aligns the item toward the start of its alignment area.
end Aligns the item toward the end of its alignment area.
center Centers the item within its available alignment area.
stretch Stretches an eligible item to fill its alignment area, subject to sizing constraints.
self-start Aligns the item toward the start side determined by its own writing mode.
self-end Aligns the item toward the end side determined by its own writing mode.
flex-start Aligns toward the flex-start side in applicable flex layouts.
flex-end Aligns toward the flex-end side in applicable flex layouts.
baseline Requests first-baseline alignment where supported.
first baseline Aligns using the first baseline of the item.
last baseline Aligns using the last baseline of the item.
safe Modifies positional alignment to avoid certain overflow situations.
unsafe Requests positional alignment even when overflow may occur.
initial Resets both longhand properties to auto.
inherit Inherits both longhand values from the parent element.
unset Resets both longhand properties to auto because they are not inherited.
revert Reverts the shorthand according to CSS cascade origin rules.
revert-layer Reverts the shorthand according to CSS cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto auto
Inherited No
Applies to Elements that support the underlying self-alignment properties
Computed value See align-self and justify-self
Animation type Discrete for the underlying alignment properties
Percentages Not applicable
Longhand properties align-self and justify-self

Valid Values

.grid-item {
  place-self: auto;
}
.grid-item {
  place-self: center;
}
.grid-item {
  place-self: start end;
}
.grid-item {
  place-self: stretch center;
}
.grid-item {
  place-self: first baseline center;
}
.grid-item {
  place-self: safe center;
}
.grid-item {
  place-self: self-start self-end;
}

Invalid Values

.grid-item {
  place-self: middle;
}
.grid-item {
  place-self: space-between;
}
.grid-item {
  place-self: 50%;
}
.grid-item {
  place-self: center, start;
}
.grid-item {
  place-self: start center end;
}

The property does not accept arbitrary keywords, content-distribution values such as space-between, percentages, comma-separated values, or three independent alignment components.

How It Works

The place-self property combines two self-alignment declarations into one shorthand.

The Two Longhand Properties

.grid-item {
  align-self: center;
  justify-self: end;
}

The equivalent shorthand is:

.grid-item {
  place-self: center end;
}

Alignment Within a Grid Area

In Grid, an item occupies a grid area. The align-self component controls its block-axis alignment, while justify-self controls its inline-axis alignment.

Overriding Container Defaults

A grid container can establish default item alignment using place-items. An individual grid item can override those defaults using place-self.

.grid-container {
  display: grid;
  place-items: center;
}
.special-item {
  place-self: end start;
}

Most items remain centered, while the selected item aligns toward the block-end and inline-start sides of its grid area.

Available Alignment Space

Alignment differences are easiest to see when the item is smaller than its grid area. If an item fills the available area, changing its alignment may produce little visible difference.

Default Behavior

With place-self: auto, each longhand uses the applicable alignment behavior established by the parent container.

Important Distinction

The property positions an individual item within its alignment area. It does not reposition the entire grid or change the placement of grid tracks.

One Value vs. Two Values

Use one value when both alignment components should match. Use two values when different alignment is needed along each axis.

One Value

.grid-item {
  place-self: center;
}

This expands to:

.grid-item {
  align-self: center;
  justify-self: center;
}

Two Values

.grid-item {
  place-self: start end;
}

This expands to:

.grid-item {
  align-self: start;
  justify-self: end;
}

Stretching Along One Axis

.grid-item {
  place-self: stretch center;
}

The item can stretch along the block axis while remaining centered along the inline axis.

Aligning Toward Different Edges

.grid-item {
  place-self: end start;
}

The item aligns toward the block-end and inline-start sides of its grid area.

Using auto

.grid-item {
  place-self: auto;
}

Both alignment components follow their applicable parent-container defaults.

Important Consideration

The shorthand sets both longhand properties, even when only one value is supplied.

Using place-self With CSS Grid

CSS Grid is the primary layout method for demonstrating how place-self aligns individual items.

Centering One Grid Item

.grid-container {
  display: grid;
  grid-template-columns: repeat(2, 150px);
  grid-auto-rows: 120px;
}
.special-item {
  place-self: center;
}

The selected item is centered within its grid area without changing the alignment of the other items.

Aligning One Item to the Start

.special-item {
  place-self: start;
}

The selected item aligns toward the start of both axes.

Aligning One Item to the End

.special-item {
  place-self: end;
}

The selected item aligns toward the end of both axes.

Using Different Values

.special-item {
  place-self: start center;
}

The item aligns toward the block-start side and centers along the inline axis.

Stretching One Item

.special-item {
  place-self: stretch;
}

An eligible item can stretch to fill its grid area, subject to sizing constraints.

Overriding place-items

.grid-container {
  display: grid;
  place-items: center;
}
.special-item {
  place-self: end start;
}

The container centers items by default, while the selected item uses different alignment.

Important Consideration

Apply place-self to the grid item itself, not to its parent container, when the goal is to override that item's alignment.

Using place-self With Flexbox

The place-self shorthand can be declared on a flex item, but only its align-self component affects the item's alignment.

Cross-Axis Alignment

.flex-container {
  display: flex;
  height: 200px;
}
.special-item {
  place-self: center;
}

In a typical row flex container, the selected item is centered vertically along the cross axis.

Why justify-self Has No Effect

Flexbox distributes items along the main axis using justify-content and flexible sizing. The justify-self property does not affect flex items.

Using align-self Directly

.special-item {
  align-self: center;
}

This is generally clearer than using place-self: center when working with Flexbox.

Aligning One Flex Item to the End

.special-item {
  align-self: flex-end;
}

The item aligns toward the cross-axis end of the flex container.

Column Flex Direction

.flex-container {
  display: flex;
  flex-direction: column;
}
.special-item {
  align-self: center;
}

In a typical horizontal writing mode, the selected item is centered horizontally because the cross axis runs horizontally.

Important Consideration

Use align-self for individual flex item alignment. Use place-self primarily when both self-alignment components are meaningful, as in CSS Grid.

Understanding Alignment Values

Different alignment values determine where an individual item sits within its available alignment area.

auto

.grid-item {
  place-self: auto;
}

Uses the applicable alignment behavior established by the parent container.

start

.grid-item {
  place-self: start;
}

Aligns the item toward the start of both axes.

end

.grid-item {
  place-self: end;
}

Aligns the item toward the end of both axes.

center

.grid-item {
  place-self: center;
}

Centers the item within its grid area.

stretch

.grid-item {
  place-self: stretch;
}

Allows the item to stretch along both axes when its sizing permits.

self-start and self-end

.grid-item {
  place-self: self-start;
}
.grid-item {
  place-self: self-end;
}

These values use the item's own writing mode to determine its start and end sides.

Baseline Alignment

.grid-item {
  place-self: first baseline;
}
.grid-item {
  place-self: last baseline;
}

Baseline alignment positions eligible items according to their content baselines.

Safe Alignment

.grid-item {
  place-self: safe center;
}

Requests centering that avoids certain overflow-related data loss.

Unsafe Alignment

.grid-item {
  place-self: unsafe center;
}

Requests centering even if the item overflows its alignment area.

Important Consideration

Content-distribution values such as space-between and space-evenly are not valid for place-self.

place-self vs. place-items

The place-self and place-items properties work together to control item alignment at different levels.

place-items

.grid-container {
  display: grid;
  place-items: center;
}

Establishes default alignment for all grid items.

place-self

.special-item {
  place-self: end start;
}

Overrides the default alignment for one selected item.

Using Both Properties

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 120px);
  grid-auto-rows: 100px;
  place-items: center;
}
.special-item {
  place-self: end start;
}

Most items remain centered, while the selected item aligns toward the block-end and inline-start sides of its grid area.

Property Comparison

Property Longhand Properties Purpose
place-content align-content, justify-content Aligns the overall content structure within a container.
place-items align-items, justify-items Sets default alignment for items within their layout areas.
place-self align-self, justify-self Controls alignment of one individual item.

Important Consideration

Use place-items for consistent container-level defaults and place-self for individual exceptions.

Item Sizing and Stretching

The visible effect of place-self depends on the item's dimensions and the available space in its alignment area.

Automatic Sizing

.grid-item {
  place-self: stretch;
}

Eligible auto-sized grid items can stretch to fill their assigned grid areas.

Fixed Width and Height

.grid-item {
  width: 80px;
  height: 50px;
  place-self: stretch;
}

Explicit dimensions can prevent the item from stretching along the corresponding axes.

Centering Fixed-Size Items

.grid-item {
  width: 80px;
  height: 50px;
  place-self: center;
}

The item retains its specified dimensions and is centered within its grid area.

Stretching Along One Axis

.grid-item {
  width: 80px;
  place-self: stretch center;
}

The item can stretch along the block axis while remaining centered along the inline axis.

Intrinsic Aspect Ratios

Images and other elements with intrinsic aspect ratios may not stretch in the same way as ordinary auto-sized grid items.

Minimum and Maximum Sizes

Properties such as min-width, max-width, min-height, and max-height can limit an item's final size.

Important Consideration

If an alignment change produces no visible difference, inspect the item's dimensions and the size of its grid area.

Writing Modes and Alignment Axes

The place-self property uses logical alignment axes, so the physical directions associated with its values can change.

Horizontal Writing Mode

.grid-item {
  writing-mode: horizontal-tb;
  place-self: start end;
}

In a typical horizontal writing mode, block-axis alignment is vertical and inline-axis alignment is horizontal.

Vertical Writing Mode

.grid-item {
  writing-mode: vertical-rl;
  place-self: start end;
}

In a vertical writing mode, the block and inline axes have different physical orientations.

Text Direction

.grid-container {
  direction: rtl;
}
.grid-item {
  place-self: start;
}

Right-to-left direction can change which physical side corresponds to inline-start.

self-start vs. start

The start value follows the alignment container's relevant axis, while self-start uses the item's own writing mode to determine the corresponding start side.

Important Consideration

Logical alignment values are useful for layouts that must adapt to different languages and writing directions.

place-self Example

The following example uses a grid container with four items. The container centers all items by default, while the second item uses place-self to override its alignment.

HTML Example

<div class="place-self-demo">
  <div class="demo-grid">
    <div class="demo-box">1</div>
    <div class="demo-box special-item">2</div>
    <div class="demo-box">3</div>
    <div class="demo-box">4</div>
  </div>
</div>

CSS Example

.place-self-demo .demo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 120px);
  gap: 10px;
  padding: 10px;
  border: 2px solid #94a3b8;
  background-color: #f1f5f9;
  place-items: center;
}
.place-self-demo .demo-box {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  background-color: #2563eb;
  color: #ffffff;
  font-weight: 700;
}
.place-self-demo .special-item {
  place-self: end start;
  background-color: #dc2626;
}
Browser Result
1
2
3
4

The blue items are centered within their grid areas because the container uses place-items: center. The red item overrides that default with place-self: end start, positioning it toward the bottom-left corner of its grid area in a typical left-to-right horizontal writing mode.

Changing the Override

.special-item {
  place-self: start end;
}

This moves the selected item toward the block-start and inline-end sides of its grid area.

Centering a Single Item

.special-item {
  place-self: center;
}

This centers the selected item along both axes.

Stretching One Item

.special-item {
  width: auto;
  height: auto;
  place-self: stretch;
}

Removing the fixed dimensions allows the selected item to stretch within its grid area, subject to other sizing constraints.

Accessibility Considerations

The place-self property changes visual alignment without changing the semantic structure or source order of HTML elements.

Maintain Logical Source Order

Keep elements in a meaningful HTML order so keyboard and screen reader navigation remain predictable.

Avoid Clipping Important Content

Alignment can position items where they overflow their grid areas. Ensure text, buttons, and links remain visible and usable.

Use Safe Alignment When Appropriate

.grid-item {
  place-self: safe center;
}

Safe alignment can help avoid certain overflow situations that might otherwise make content difficult to access.

Support Responsive Layouts

Test individual item alignment at different viewport sizes. An item that fits comfortably in a wide grid area may overflow a narrow one.

Preserve Interactive Target Sizes

When aligning interactive elements, maintain adequate clickable and touch-friendly target sizes.

Important Consideration

Visual positioning should not make an element appear disconnected from its surrounding content or expected reading order.

Common Mistakes

Applying place-self to the Container

.grid-container {
  display: grid;
  place-self: center;
}

This does not center the container's children within their grid areas. Use place-items: center on the container instead. The place-self declaration may affect the container's own alignment if it is itself a grid item.

Confusing place-self With place-items

place-items establishes default alignment for items, while place-self overrides alignment for an individual item.

Expecting Both Axes to Work in Flexbox

.flex-item {
  place-self: center;
}

Only the align-self component affects flex items. The justify-self component has no effect in Flexbox.

Using Content-Distribution Values

.grid-item {
  place-self: space-between;
}

The space-between value is not valid for self-alignment.

Using Percentages

.grid-item {
  place-self: 50%;
}

Percentages are not valid alignment values.

Using Commas

.grid-item {
  place-self: center, end;
}

Use spaces between alignment components, not commas.

Using Three Independent Values

.grid-item {
  place-self: start center end;
}

The shorthand accepts one or two alignment components.

Ignoring Fixed Dimensions

Explicit widths and heights can prevent stretching or make some alignment changes less noticeable.

Assuming start Always Means Left

The physical direction of start depends on the alignment axis, writing mode, and text direction.

Overwriting Longhand Values

.grid-item {
  justify-self: end;
  place-self: center;
}

The later shorthand resets both align-self and justify-self to center.

Expecting Grid Track Movement

place-self does not move grid tracks or redistribute space between them. It aligns the selected item within its assigned area.

Important Considerations

Keep the following points in mind when using place-self:

  • It is a shorthand for align-self and justify-self.
  • Its initial longhand values are both auto.
  • The property is not inherited.
  • It accepts one or two alignment components.
  • The first component sets align-self.
  • The second component sets justify-self.
  • When one value is supplied, it applies to both longhand properties.
  • It is especially useful for individual CSS Grid items.
  • In Grid, it controls alignment within the item's assigned grid area.
  • It does not change grid track placement or distribution.
  • Use place-items to establish default alignment for all grid items.
  • Use place-self to override the alignment of one item.
  • Use place-content to align the overall grid structure.
  • In Flexbox, only the align-self component affects flex item alignment.
  • The justify-self component has no effect on flex items.
  • Use justify-content to distribute flex items along the main axis.
  • auto follows the applicable parent-container alignment defaults.
  • center centers an item within its alignment area.
  • start and end use logical alignment directions.
  • stretch can expand eligible items within their alignment areas.
  • Fixed dimensions and intrinsic aspect ratios can limit stretching.
  • Baseline alignment uses the item's content baselines where supported.
  • safe and unsafe modify supported positional alignment values.
  • Content-distribution values such as space-between are not valid.
  • Percentages are not accepted as alignment values.
  • Alignment components are separated by spaces, not commas.
  • The shorthand resets both underlying longhand properties.
  • Logical alignment directions depend on writing mode and text direction.
  • Alignment changes do not alter HTML source order.
  • Test item sizing and alignment at different viewport widths.
  • Ensure aligned interactive elements remain visible and accessible.

Browser Support

The CSS place-self property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.

The shorthand is well supported, but its visible effect depends on the layout method. In Flexbox, justify-self does not affect flex items, so only the align-self component contributes to alignment.

For current compatibility information, visit Can I Use? and search for place-self.

Specifications

The place-self property is defined in CSS Box Alignment Module Level 3.

CSS Box Alignment Module Level 3

The specification defines the shorthand syntax and its relationship to align-self and justify-self.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: place-self