HTML Compiler Online
Javascript Online Compiler
index.html
Change Theme
Compress code
Format code
Download Code
Clear Code
Copy Code!
RunĀ
ctrl+s or click
Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Article - center vertically table cell</title> <style> .parent { display: table-cell; vertical-align: middle; height: 200px; border: 2px solid #4B5681; background: #7E89B4; } .child { display: inline-block; height: 100px; width: 200px; background: #353C5A; font-family: sans-serif; color: white; } </style> </head> <body> <h2>To align a div element to the center vertically you can set parent element to display-cell.</h2> <p>Now no one use table to align elements but it's good to know.</p> <div class="parent"> <div class="child">Child</div> </div> </body> </html>
RunĀ