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 horizontally table</title> <style> .parent { text-align: center; width: 100vw; border: 2px solid #4B5681; background: #7E89B4; height: 100px; } .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 horizontally you can use table and apply CSS property over it.</h2> <p>Now no one use table to align elements but it's good to know.</p> <table> <tbody> <tr> <td class="parent"> <div class="child">Child</div> </td> </tr> </tbody> </table> </body> </html>
RunĀ