Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> body { background: #c2c2c2; font-size: 90%; } table { background: #fff; width: 200px; border-collapse: separate; margin: 15px; height: 200px; } table td { background: #83d483; color: #fff; padding: 15px; border: 5px solid #fff; /* default is vertical-align: middle; */ } .center-table { display: table; height: 200px; background: #fff; width: 200px; margin: 20px; } .center-table p { display: table-cell; margin: 0; background: #83d483; color: #fff; padding: 20px; border: 5px solid #fff; vertical-align: middle; } </style> </head> <body> <table> <tr> <td>Example of vertically centered multiple lines of text in a table cell.</td> </tr> </table> <div class="center-table"> <p>Example of vertically centered multiple lines of text in a CSS-created table layout.</p> </div> </body> </html>