DevSolve

How to centre a div in HTML

How do I centre a div with HTML and CSS (JS is banned)

1 month ago comments


Comments

why u need js to center a div?

<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0;">stuff</div>

<div style="text-align: center;">Centered Content</div>

<div style="text-align: center;">Centered Content</div>

indeed.

good question!

why would you need JS for centering a div?

why would you need JS for centering a div?

Why is JS banned?

<div style="width:800px; margin:0 auto;"> centered content </div>

i will center your div just give me all your robux

Use flex!

flexbox