Home
CSS
CSS Align
Tryit: Center with flexbox
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> .center { display: flex; justify-content: center; align-items: center; height: 200px; border: 3px solid green; } </style> </head> <body> <h2>Flexbox Centering</h2> <p>A container with both the justify-content and the align-items properties set to <em>center</em> will align the item(s) in the center (in both axis).</p> <div class="center"> <p>I am vertically and horizontally centered.</p> </div> </body> </html>