The Fundamentals of CSS Alignment
September 15, 2025

While centering elements in CSS has become easy over time, there is still a lot of confusion around alignment in general. Let’s be honest, you always end up trying different combinations until it works, but you don’t really understand how it works, right?
Which property is for vertical alignment?
align-content
oralign-items
? Where should I adddisplay: flex
? Let’s add it everywhere! A height? Why do I need to define a height!? Maybe I should try withdisplay: grid
?It’s time to clear all the confusion! Through this exploration, you will understand the logic behind all the alignment properties and how they work in each layout. It’s not another article about centering, we are going beyond!
I’m going to admit it, I still find myself either looking up CSS Tricks’ great Flex cheat sheets or using my browser’s dev tools to remember which particular property and value will achieve my desired flex layout.
But this article lays it all out in clinical detail.