<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style type="text/css"> div { display: table-cell; width: 250px; height: 200px; vertical-align: middle; } </style> </head> <body> <div>Vertically aligned text</div> </body> </html>
vertical-align: middle;
/* HTML: */ <div class="text"> lorem ipsum </div> /* CSS: */ .text { vertical-align: middle; /*can take any value of: baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length> */ }
.center { display: flex; justify-content: center; align-items: center; height: 200px; border: 3px solid green; }
DIV.container { min-height: 10em; display: table-cell; vertical-align: middle } ... DIV { GeeksforGeeks }
.center { padding: 70px 0; border: 3px solid green; text-align: center; }