CSS
CSS AlignCSS Align
CSS centers and aligns elements horizontally and vertically.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
CSS provides multiple ways to center text and elements. You can center text easily using text alignment. To center a physical block element, developers set an exact width and use auto margins.
Syntax
Syntax
Example
Example
Key Points
- The `text-align: center` property centers inner text.
- The `margin: auto` property horizontally centers block elements.
- Centering a block requires a defined width.
- Flexbox provides simpler centering tools today.