Skip to main content

How do you align an element individually?

To align a single flex item individually, the following property is used:

javascript
align-self

This property overrides align-items, but only for a specific element. Example:

css
.item { align-self: center; }

The possible values match those of align-items:

javascript
align-self: auto | flex-start | flex-end | center | baseline | stretch;

Also, if you need to align an element along the main axis individually, you can use margin: auto;: a specific trick that lets you "push" the element away from the others in the needed direction. For example:

css
.item { margin-left: auto; /* push the element to the right in a row direction */ }

Summary

PropertyWhat for
align-selfindividual alignment along the cross axis
margin:autoindividual alignment along the main axis (a trick for a single element)

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.

How do you align an element individually?: CSS Interview Question