DEV Community

Coder rudra
Coder rudra

Posted on

Top 2 Simple Way to CENTER A DIV

1> the most common one this one is so simple that we can do this with HTML

<center>
    <p>B)</p>
</center>
Enter fullscreen mode Exit fullscreen mode

2> percentage! if you don't understand what I am trying to say that we can use percentage to center a div by CSS here is an example:


.center {
   position: absolute;
   top: 50%;
   left: 50%;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)