CSS place-content

View Output Full Screen Preview

The CSS place-content property is a shorthand property for the align-content and justify-content properties.

The first value sets align-content and the second value sets justify-content. If only one value is provided, it sets both properties.

Syntax

These values are explained below.

Possible Values

normal
Represents the "default" alignment for the layout mode.

baseline-position

The first and last values give a box a baseline alignment preference. The default value is first.

Values:

baseline
Computes to first baseline.
first baseline
Aligns the alignment baseline of the box's first baseline set with the corresponding baseline of its alignment context. The fallback alignment for first baseline is start.
last baseline
Aligns the alignment baseline of the box's last baseline set with the corresponding baseline of its alignment context. The fallback alignment for last baseline is end.

content-distribution

Possible values:

space-between

The alignment subjects are evenly distributed in the alignment container. The first alignment subject is placed flush with the start edge of the alignment container, the last alignment subject is placed flush with the end edge of the alignment container, and the remaining alignment subjects are distributed so that the spacing between any two adjacent alignment subjects is the same.

The default fallback alignment for this value is start.

space-around

The alignment subjects are evenly distributed in the alignment container, with a half-size space on either end. The alignment subjects are distributed so that the spacing between any two adjacent alignment subjects is the same, and the spacing before the first and after the last alignment subject is half the size of the other spacing.

The default fallback alignment for this value is center.

space-evenly

The alignment subjects are evenly distributed in the alignment container, with a full-size space on either end. The alignment subjects are distributed so that the spacing between any two adjacent alignment subjects, before the first alignment subject, and after the last alignment subject is the same.

The default fallback alignment for this value is center.

stretch

If the combined size of the alignment subjects is less than the size of the alignment container, any auto-sized alignment subjects have their size increased equally (not proportionally), while still respecting the constraints imposed by the max-height/max-width properties (or equivalent functionality), so that the combined size exactly fills the alignment container.

The default fallback alignment for this value is flex-start.

content-position

Possible values:

center
Centers the alignment subject within its alignment container.
start
Aligns the alignment subject to be flush with the alignment container's start edge in the appropriate axis.
end
Aligns the alignment subject to be flush with the alignment container's end edge in the appropriate axis.
flex-start
Only used in flex layout. The cross-start margin edge of the flex item is placed flush with the cross-start edge of the line.
flex-end
Only used in flex layout. The cross-end margin edge of the flex item is placed flush with the cross-end edge of the line.
left
Aligns the alignment subject to be flush with the alignment container's line-left edge. If the property's axis is not parallel with the inline axis, this value behaves as start.
right
Aligns the alignment subject to be flush with the alignment container's line-right edge. If the property's axis is not parallel with the inline axis, this value behaves as start.

In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:

initial
Represents the value specified as the property's initial value.
inherit
Represents the computed value of the property on the element's parent.
unset
This value acts as either inherit or initial, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.

Basic Property Information

Initial Value
See individual properties
Applies To
Block containers, flex containers, and grid containers
Inherited?
No
Media
Visual
Animatable
No

Example Code

Basic CSS

Working Example within an HTML Document

This example uses CSS grid. It aligns grid items within a grid container.

View Output Full Screen Preview

CSS Specifications

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

Browser Support

Browser support for CSS properties can vary, particularly for newer or experimental features. Check current browser compatibility before using a property in production, especially when supporting older browsers.

The following table provided by Caniuse.com shows the level of browser support for this feature.

Initial Value

CSS properties have an initial value that applies when the property has not been explicitly set. The initial value is different from the value inherited from a parent element and may vary between properties.

Inheritance

Some CSS properties inherit their computed value from their parent element by default, while others do not. The inherit, initial, unset, and revert keywords can also be used to control how a property gets its value.

Vendor Prefixes

Most modern CSS properties use the standard, unprefixed syntax. Vendor-prefixed properties such as -webkit- are mainly relevant to older browser versions or specific features and should only be used when required by your browser support targets.