1. css
  2. /properties
  3. /justify-self

justify-self

Definition

The justify-self property is used to align a grid item along the horizontal axis within a grid cell. It overrides the default value of justify-items set on the grid container for that particular item. This property applies only to grid items.

Examples

Setting justify-self to start:

.grid-item {
  justify-self: start;
}

Setting justify-self to center:

.grid-item {
  justify-self: center;
}

Setting justify-self to end:

.grid-item {
  justify-self: end;
}

Values

ValueDescription
autoDefault value. Grid item inherits the value of justify-items from its grid container.
stretchGrid item is stretched to fill the grid cell.
centerGrid item is centered within the grid cell.
startGrid item is aligned with the start of the grid cell.
endGrid item is aligned with the end of the grid cell.
baselineGrid item is aligned with the text baseline within the grid cell.
first baselineGrid item is aligned with the first text baseline within the grid cell.
last baselineGrid item is aligned with the last text baseline within the grid cell.

Best Practices

  • Use justify-self to align individual grid items within a grid cell.
  • Use justify-items to set the default horizontal alignment of all grid items within a grid container.
  • Avoid using justify-self on non-grid items as it has no effect.
  • Use auto for justify-self if you want the grid item to inherit the default horizontal alignment set on the grid container.
  • Always test your layout on different screen sizes and devices to ensure that it looks good and is aligned as expected.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera
YesYesYesYesYesYes