place-self
Quick Summary for place-self
The place-self CSS shorthand property allows you to align an individual item in both the block and inline directions at once (i.e. the align-self and justify-self properties) in a relevant layout system such as Grid or Flexbox. If the second value is not present, the first value is also used for it.
Code Usage for place-self
/* Keyword values */ place-self: auto center; place-self: normal start;  /* Positional alignment */ place-self: center normal; place-self: start auto; place-self: end normal; place-self: self-start auto; place-self: self-end normal; place-self: flex-start auto; place-self: flex-end normal; place-self: left auto; place-self: right normal;  /* Baseline alignment */ place-self: baseline normal; place-self: first baseline auto; place-self: last baseline normal; place-self: stretch auto;  /* Global values */ place-self: inherit; place-self: initial; place-self: revert; place-self: unset; 
More Details for place-self

place-self

The place-self CSS shorthand property allows you to align an individual item in both the block and inline directions at once (i.e. the align-self and justify-self properties) in a relevant layout system such as Grid or Flexbox. If the second value is not present, the first value is also used for it.

Constituent properties

This property is a shorthand for the following CSS properties:

align-self justify-self

Syntax

/* Keyword values */ place-self: auto center; place-self: normal start;  /* Positional alignment */ place-self: center normal; place-self: start auto; place-self: end normal; place-self: self-start auto; place-self: self-end normal; place-self: flex-start auto; place-self: flex-end normal; place-self: left auto; place-self: right normal;  /* Baseline alignment */ place-self: baseline normal; place-self: first baseline auto; place-self: last baseline normal; place-self: stretch auto;  /* Global values */ place-self: inherit; place-self: initial; place-self: revert; place-self: unset; 

Values

auto

Computes to the parent's align-items value.

normal

The effect of this keyword is dependent of the layout mode we are in:

In absolutely-positioned layouts, the keyword behaves like start on replaced absolutely-positioned boxes, and as stretch on all other absolutely-positioned boxes. In static position of absolutely-positioned layouts, the keyword behaves as stretch. For flex items, the keyword behaves as stretch. For grid items, this keyword leads to a behavior similar to the one of stretch, except for boxes with an aspect ratio or an intrinsic sizes where it behaves like start. The property doesn't apply to block-level boxes, and to table cells. self-start

Aligns the items to be flush with the edge of the alignment container corresponding to the item's start side in the cross axis.

self-end

Aligns the items to be flush with the edge of the alignment container corresponding to the item's end side in the cross axis.

flex-start

The cross-start margin edge of the flex item is flushed with the cross-start edge of the line.

flex-end

The cross-end margin edge of the flex item is flushed with the cross-end edge of the line.

center

The flex item's margin box is centered within the line on the cross-axis. If the cross-size of the item is larger than the flex container, it will overflow equally in both directions.

baseline, first baseline. last baseline

Specifies participation in first- or last-baseline alignment: aligns the alignment baseline of the box's first or last baseline set with the corresponding baseline in the shared first or last baseline set of all the boxes in its baseline-sharing group. The fallback alignment for first baseline is start, the one for last baseline is end.

stretch

If the combined size of the items along the cross axis is less than the size of the alignment container and the item is auto-sized, its size is increased equally (not proportionally), while still respecting the constraints imposed by max-height/max-width (or equivalent functionality), so that the combined size of all auto-sized items exactly fills the alignment container along the cross axis.

Formal definition

Initial valueas each of the properties of the shorthand:align-self: autojustify-self: auto
Applies toblock-level boxes, absolutely-positioned boxes, and grid items
Inheritedno
Computed valueas each of the properties of the shorthand:align-self: auto computes to itself on absolutely-positioned elements, and to the computed value of align-items on the parent (minus any legacy keywords) on all other boxes, or start if the box has no parent. Its behavior depends on the layout model, as described for justify-self. Otherwise the specified value.justify-self: as specified
Animation typediscrete

Formal syntax

<'align-self'> <'justify-self'>?

Examples

Simple demonstration

In the following example we have a simple 2 x 2 grid layout. Initially the grid container has justify-items and align-items values of stretch — the defaults — which causes the grid items to stretch across the entire width of their cells.

The second, third, and fourth grid items are then given different values of place-self, to show how these override the default placements. These values cause the grid items to span only as wide/tall as their content width/height, and align in different positions across their cells, in the block and inline directions.

HTML
<article class="container">   <span>First</span>   <span>Second</span>   <span>Third</span>   <span>Fourth</span> </article> 
CSS
html {   font-family: helvetica, arial, sans-serif;   letter-spacing: 1px; }  article {   background-color: red;   display: grid;   grid-template-columns: 1fr 1fr;   grid-auto-rows: 80px;   grid-gap: 10px;   width: 300px; }  span:nth-child(2) {   place-self: start center; }  span:nth-child(3) {   place-self: center start; }  span:nth-child(4) {   place-self: end; }  article span {   background-color: black;   color: white;   margin: 1px;   text-align: center; }  article, span {   padding: 10px;   border-radius: 7px; }  article {   margin: 20px; } 
Result

Specifications

Specification
CSS Box Alignment Module Level 3 # place-self-property

See also

CSS Flexbox Guide: Basic Concepts of Flexbox CSS Flexbox Guide: Aligning items in a flex container CSS Grid Guide: Box alignment in CSS Grid layouts CSS Box Alignment The align-self property The justify-self property

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
You want to be the best, you MUST put the long yards in! Nothing comes easy in life so stop wishing and start DOING! So many people would rather bitch and moan than help themselves. Dont be one of those negative drainers, start today, make a small change and keep going forwards with this attitude!
Unknown
Random CSS Property

column-rule-color

The column-rule-color CSS property sets the color of the line drawn between columns in a multi-column layout.
column-rule-color css reference