Run ยป
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> body{ margin: 10px; font-size: 15px; } .container-5{ width: 750px; float: left; height: 400px; background-color: cadetblue; display: flex; align-items: center; justify-content: center; } .container-5 .center{ width: 300px; height: 150px; background-color: white; } </style> </head> <body> <h2>2. Center div tag with flex</h2> <div class="container-5"> <div class="center"> Center box with flex </div> </div> </body> </html>