Home
CSS
CSS Align
Tryit: Center with padding and text-align
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 { padding: 70px 0; border: 3px solid green; text-align: center; } </style> </head> <body> <h2>Center with padding and text-align</h2> <p>In this example, we use padding and text-align to center the div element both vertically and horizontally:</p> <div class="center"> <p>I am vertically and horizontally centered.</p> </div> </body> </html>