{"id":336695,"date":"2021-03-18T12:08:48","date_gmt":"2021-03-18T19:08:48","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=336695"},"modified":"2022-04-28T12:13:31","modified_gmt":"2022-04-28T19:13:31","slug":"justify-self","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/j\/justify-self\/","title":{"rendered":"justify-self"},"content":{"rendered":"\n

The justify-self<\/code> property in CSS sets the justification of an element within its containing block. Its behavior depends on the display<\/code> of the containing block. For example, if the containing block is a grid container (i.e. display: grid<\/code>), we can justify the element in it along the “inline” axis (which, in turn, can be vertical or horizontal based on the content direction<\/code>).<\/p>\n\n\n\n

.element {\n  justify-self: start;\n}<\/code><\/pre>\n\n\n\n\n\n\n\n

justify-self<\/code> is defined in the CSS Box Alignment Module Level 3 specification<\/a>.<\/p>\n\n\n

Let’s talk about direction<\/h3>\n\n\n

Direction is a relative thing in CSS. You may be used to thinking of direction in terms of offsets, like top<\/code>, bottom<\/code>, left<\/code> and right<\/code>. But not all languages think in the same left-to-right (LTR) orientation. That’s why CSS is leaning hard in the direction<\/em> (pun intended) of logical properties<\/strong>.<\/p>\n\n\n\n

Logical properties in CSS take the direction<\/a><\/code>, text-orientation<\/a><\/code>, and writing-mode<\/a><\/code> of the content into consideration, then treat the inline and block directions accordingly. So, in a left-to-right writing mode, inline means left and right, and block means top and bottom. In a vertical writing mode, inline means top and bottom, and block means left and right. That’s the “logic” in logical properties, like margin-inline<\/a><\/code> and margin-block<\/a><\/code> among many other properties.<\/p>\n\n\n\n

\"\"
In \u201cnormal\u201d LTR writing conditions, the vertical axis will have the suffix -block<\/code> and the horizontal axis will have the suffix -inline<\/code>, both followed by start<\/code> or end<\/code>.<\/figcaption><\/figure>\n\n\n\n

What does this have to do with justify-self<\/code>? Well, it uses keyword values\u2009\u2014\u2009like start<\/code> and end<\/code>\u2009\u2014\u2009that mean different things in different contexts. justify-self<\/code> aligns an element along the inline<\/em> axis which is horizontal in an LTR writing mode, but otherwise vertical.<\/p>\n\n\n

Syntax<\/h3>\n\n\n
justify-self: auto | normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ]<\/code><\/pre>\n\n\n\n\n

Values<\/h3>\n\n\n
\/* Basic keywords *\/\njustify-self: auto;\njustify-self: normal;\njustify-self: stretch;\n\n\/* Postion keywords *\/\njustify-self: start;\njustify-self: end;\njustify-self: center;\njustify-self: left;\njustify-self: right;\njustify-self: flex-start;\njustify-self: flex-end;\njustify-self: self-start;\njustify-self: self-end;\n\n\/* Baseline keywords *\/\njustify-self: baseline;\njustify-self: first-baseline;\njustify-self: last-baseline;\n\n\/* Overflow keywords *\/\njustify-self: safe center;\njustify-self: unsafe center;\n\n\/* Global keywords *\/\njustify-self: inherit;\njustify-self: initial;\njustify-self: unset;<\/code><\/pre>\n\n\n

Basic keyword values<\/h4>\n\n\n