Contact Us | +1 888 239-0733 (Toll free US/CA) Mon-Fri: 7:30am to 4:30pm (PST)

CSS 'align-items' Property Explained

Est. Reading: 1 minute
Updated: April 2, 2024

The CSS 'align-items' property is a key player in Flexbox and Grid layouts, providing a way to align child elements (items) within their container vertically. Think of it as the tool that determines how items line up along the cross-axis (typically up and down if your flex-direction is row-wise), especially when the items do not all have the same height.

CSS 'align-items' Property Examples

See the Pen CSS 'align-items' Property by Webzstore (@webzstore) on CodePen.

Items are aligned based on the baseline of their content, which is particularly noticeable when text sizes differ.

Browser Support For 'align-items' Property

FirefoxSafariChromeMicrosoft EdgeOpera
52.010.157.016.044.0

CSS Syntax of the 'align-items' Property

align-items: stretch|flex-start|flex-end|center|baseline|initial|inherit;

Usage of the 'align-items' Property

You'd use 'align-items' to control the vertical alignment of items within a flex container (or grid items within a grid container along the block axis). This property is incredibly useful for ensuring consistent vertical spacing, alignment, and space distribution among items that may vary in size or to match a specific design requirement.

Property Values of the 'align-items' Property

  • Stretch: The default value. Items are stretched to fit the container's height.
  • Flex-start: Items are aligned to the start of the container.
  • Flex-end: Items are aligned to the end of the container.
  • Center: Items are centered within the container.
  • Baseline: Items are aligned based on their baseline.
  • Initial: Sets this property to its default value (stretch).
  • Inherit: Inherits this property from its parent element.

Ryan Parker

Ryan has been a standout in digital marketing since 2010. He's the go-to person for getting businesses noticed online, with over 300 projects under his belt—these range from helping local business owners to big online stores. As the Head of Digital Marketing at Webzstore Solutions, Ryan knows all the tricks to make companies shine on the internet. He's excellent at using the latest tech and smart strategies to get results. Ryan is all about making businesses grow and reach more people online.

chevron-down