Skip to main content

Creative Bloq is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more

How to do vertical centering in CSS

It feels like it should be a simple task but it's easy to tie yourself in knots if you don't know any good tricks for vertical centering. Jake Archibald has two neat ways for vertically centering things in CSS.

Here's his method for modern browsers, as hosted on the collaborative code pastebin JsBin:

Vertical centering in modern browsers, by Jake Archibald

Click on the image to see a larger version

And here's one that works for browsers going back to IE8:

Archibald's method for centering in old browsers

Click on the image to see a larger version

You can follow some further discussion about these and other methods on Twitter, here.

Liked this? Read these!