Search⌘ K

Centering

Explore multiple techniques to center content using CSS. Understand how to center inline and block elements horizontally, vertically, or both, leveraging Flexbox and Grid. Gain practical skills to control layout alignment efficiently for modern web pages.

Centering

Centering is the act of putting something in the middle of a page. It’s often much easier said than done! This is because there are many different ways to center elements. The way to do it is determined by whether we’re centering horizontally, vertically, or both!

In this lesson, we’ll look at how to do it best in each scenario.

Horizontal centering

Inline elements

Inline elements such as text can be centered horizontally with the text-align ...