DEV Community

Cover image for How to center a div in just 4 lines of code!!!
Shubham Jadhav
Shubham Jadhav

Posted on

How to center a div in just 4 lines of code!!!

Hey coders, Let's add a empty container in center of web page in just 4 lines of code.

1.First we need index.html and
a style.css.
2.Let's create a empty div in
index.html file. And give
demo as class name.
Div tag

  1. Now give some style to this
    empty div to we can see it.
    style demo class

  2. Let's get it in center vertically and also horizontally in just four lines of code.
    5.Code is below
    Alt Text

6.Stay tuned with me I am sharing all my trick and tips.
🙏 Thank you for reading
👆 If you like this then hit
đź‘Ť Like button

Top comments (0)