HN Hall of Fame Weekly email

How to Center in CSS

howtocenterincss.com Tools, games & demos Interactive tools & demos Web & internet Class of 2020-05 Hall of Fame
Screenshot of howtocenterincss.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 3 calendar years, with breakout response in 3 of them.

submissions
6
submitters
6
observed span
2015–2020
peak thread · 289 comments
1036 pts
latest 20+ return · 2020-05-19
161 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

The mere fact that a site like this can exist and not be a joke is proof that CSS is still badly broken. I should be able to center things by writing: foo { align: center; valign: center; }

lisper·1036-point thread·

Centering in CSS is "solved" problem if your "worst" browser to support is IE11. Flexbox does the job there. However, there are still couple of common tasks that are pain/hard/impossible to do with just CSS. Recently I learned that after all this years you still need to use JS to get css animation for dynamic height ("height:auto") of elements. And there is no progress in fixing it at CSS standard level. It's just sad... https://github.com/w3c/csswg-drafts/issues/626…

Can someone explain to me what is this for if selecting 4 x unknown in all questions leads to this? <div style="margin-left:auto;margin-right:auto;"> (DIV) <div style="text-align:center;">Text Content</div> (TEXT) If this is supposed to work, then by reduction, having more information about height/width is unnecessary for both browser and CSS programmer. Why not just always use those two forms?

jakubp·135-point thread·

Just found previous discussion from 2015: https://news.ycombinator.com/item?id=9405284 Source code: https://github.com/oliverzheng/howtocenterincss

vanni·6-point thread·

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
3

100+ points or 50+ comments

Total points
1340

reference only — not used in Hall rules or ranking

Total comments
398

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2015-04-13Howtocenterincss.comionicabizau10
2015-04-19How to Center in CSSFirst breakout · Best threadplurby1036289
2016-05-14How to Center in CSSvdfs13539
2016-08-04How to Center in CSSAdamFernandez10
2016-12-22How to Center in CSS – Online tool to generate code for every situationvanni61
2020-05-19How to Center in CSS (2015)Hall induction · Latest 20+ point returnHeinZawHtet16169