CSS Align
CSS Layout - Horizontal & Vertical Align.
There are many ways to center elements in CSS.
Center Align Elements
To horizontally center a block element (like <div>), use margin: auto;. Setting the width of the element will prevent it from stretching out to the edges of its container.
Preview
Center Align Text
To just center the text inside an element, use text-align: center;.
Preview
Center Vertically - Using Padding
There are many ways to center an element vertically in CSS. A simple solution is to use top and bottom padding.
Preview