Align-self - Property CSS
Summary of characteristics of the align-self property
auto | normal | stretch | center | start | end | flex-start | flex-end | baseline | first baseline | last baselineautoDiscrète: during an animation, the align-self property passes from one value to another without transition.Per grammar: serialization in the order of syntax.Align-self syntax.
align-self property.[The links in the diagram provide more details about the values.}
Download the diagram in SVG
* indicates a default value, which can be omitted.
Description of align-self.
align-self is a CSS property. It manages the alignment of one of the internal elements in a flexible container or in a grid.
It allows you to manage element-by-element alignment, unlike the align-content and align-items properties, which act on
all the elements.
When applied to an element in a flex-box, the align-self property manages the position of that element along the secondary axis.
Most of the time, for Latin languages, this will be the vertical axis.
Remember: the choice of the primary and secondary axis in a flex-box is defined by the flex-direction property.

Applied to an element in a grid, align-self manages the position of that element in its cell, along the line axis (vertical).
For a detailed overview of the possibilities of flex-boxes or grids, see flex and 
grid.
Other properties to know.
These properties all relate to the positioning of elements.
Values for align-self.
In the explanations below, we have considered that the main axis of the flex-box is the horizontal axis. The secondary axis is therefore the vertical axis. This arrangement is most common for Latin languages.
- align-self: auto;
The element is positioned like all the others, according to the
align-itemsproperty of the flex-box container.AaAaAaAaAaAa - align-self: stretch;
The element is stretched to fill the entire height of the line. To make the effect visible, the
align-itemsproperty of the container has been set the valuestart.AaAaAaAaAaAa - align-self: center;
The element is centered vertically in its line.
AaAaAaAaAaAa - align-self: flex-start; align-self: start;
The element is positioned at the top of its line.
The first value is more suitable for the flex-box container, while the second is rather reserved for grids but browsers don't make a difference.AaAaAaAaAaAa - align-self: flex-end; align-self: end;
The element is positioned at the bottom of its line.
The first value is more suitable for flex-box containers, while the second is more reserved for grids, but browsers don't make a difference.AaAaAaAaAaAa - align-self: self-start; align-self: self-end;
The element is positioned at the bottom or top of its row height, given its own write settings.
The two green elements below have their
align-selfproperty set tostart, both have a vertical write mode, but the second to writing direction from bottom to top. This has an impact on their positioning./* 1st Element Styles */ /* Second element styles */ writing-mode:vertical-rl; writing-mode:vertical-rl; direction:ltr; direction:rtl; align-self:self-start; align-self:self-start;AaAaAaAaAaAa - align-self: baseline; align-self: first baseline; align-self: last baseline;
The element is positioned vertically relative to the text baseline.
Becausealign-selfapplies to individual elements in the flex box or grid, theBaselinevalue gives the desired result only if at least two elements in the row are aligned along that value.
In the example below, the first three elements are aligned to the text baseline (
align-self:baseline). The first example aligns to the first line, and the second example to the last line. It can be seen that, despite their different font sizes, and theirpaddingalso different, The text baselines are aligned.Aa1
Aa2
Aa3Aa
AaAaAaAaAaalign-self:first baseline;Aa1
Aa2
Aa3Aa
AaAaAaAaAaalign-self:last baseline; - align-self: safe center; align-self: unsafe end;
The words
safeandunsafecan be associated with an alignment of the typecenterorend(unsafebeing by default, it is rare to specify it).safesolves the problem of overflow from the top: if the contents are too large for the available space, they can end up hidden. If the element is centered or aligned from the bottom, this overflow can be done from the top of the element (it is the beginning of the text that is hidden). In that case even the scroll bar will not show the part of the content that is hidden.With the word
safe, the browser will always place the overflows of content downwards, even if it means not scrupulously respecting the requested alignment. Theunsafevalue, on the other hand, requires that the alignment be respected, even if this causes an upward overflow.For the operation to be correct, you must also apply
safeon the container withalign-content.Aa1
Aa2
Aa3
Aa4
Aa5
Aa6
Aa7Aa
AaAaAaAaAaIllustration of the problem
of overflow from the top.Aa1
Aa2
Aa3
Aa4
Aa5
Aa6
Aa7Aa
AaAaAaAaAaSolving problem with
align-content:safe end;on the containeralign-items:safe end;on the elements - align-self: initial; (
auto) align-self: inherit; align-self: revert; align-self: revertLayer; align-self: unset;Common values are presented on these pages:
initial,inherit,revert,revert-layer,unset.
Animation of the align-self property.
The align-self property is of the discrete type, which means that animations abruptly switch it from one value to another.
Manipulating the align-self property programmatically.
Force the value of align-self in Javascript.
Javascript offers a syntax with kebab-case notation (a dash to separate words),
and another syntax with camel-case notation (a capital letter to separate words).

let el = document.getElementById('id');
el.style['align-self'] = 'center';
// or
let el = document.getElementById('id');
el.style.alignSelf = 'center';
Read the value of align-self in Javascript.
The property must have been assigned directly to the element itself and not through a selector.
That is, this code explores the style attribute of the element.
The value is returned as it was defined: one of the values accepted by the property.

let el = document.getElementById('id');
let value = el.style['align-self'];
// or
let el = document.getElementById('id');
let value = el.style.alignSelf;
Read the computed value of align-self in Javascript.
The computed value is the value that has been assigned to the item, either directly or through a selector, or the value that results from the inheritance mechanism.
Otherwise, e will be the initial value of the property: auto in the case of align-self.

let el = document.getElementById('id');
let value = window.getComputedStyle(el).getPropertyValue('align-self');
Change the align-self property with JQuery.
JQuery also provides a syntax (shorter than Javascript) for reading and writing this property.

$('#id').css('align-self', 'center');
// or
$('#id').css('alignSelf', 'center');
Read the value computed with JQuery.

let value = $('#id').css('align-self');
Test it yourself.
The buttons below apply the entered value to the align-self property and then display either the value as applied,
or the computed value. This second option allows you to see how the value of align-self is stored (serialized).
That said, in the case of align-self, it won't make much of a difference.
Using align-self on a flex-box and a grid.
The simulator below adjusts the align-self property of blocks 2 and 3 (outlined in red),
Both in the flex-box (first example) and in the grid (second example).
The font sizes of each element are different to show the effect of the baseline value.
flex-direction : (pour le flex box).
Browser compatibility.
the align-self property in the context of a flex-box container.the align-self property in the context of a grid.start and end values for the align-self property.Notes:
(1) Internet Explorer 10 and 11 have the property -ms-grid-row-align which acts in a similar way to align-self.
align-selfproperty
(flex-box)
align-selfproperty
(grid)
start and endvalues
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

KaiOS Browser

Opéra Mobile

Edge

Opéra

Safari

Safari sur IOS

Androïd Brower

Chrome pour Androïd

Firefox pour Androïd

Samsung Internet

Firefox

Chrome

Baidu Browser

QQ Browser

UC Browser pour Androïd

Opéra mini
align-self property history.
Alignment properties (including align-self) have been introduced in the specifications for grids and flex-boxes.
A module specific to alignments was then added. It includes descriptions of all properties related to block alignments.
-
CSS Flexible Box Layout Module Level 1
Initial definition of thealign-selfproperty in the context of a flex-box.July 23, 2009Working Draft.September 18, 2012Candidate Recommendation. -
CSS Grid Layout Module Level 1
Initial definition of thealign-selfproperty in the context of a grid.April 07, 2011Working Draft.September 29, 2016Candidate Recommendation. -
CSS Grid Layout Module Level 2
No change directly affecting thealign-selfproperty.February 06, 2018Working Draft.August 18, 2020Candidate Recommendation. -
CSS Box Alignment Module Level 3
The description of thealign-selfproperty is transferred to this module of the standard.June 12, 2012Working Draft.
Other properties of CSS Box Alignment Module.
Properties:












