Why is there no float center in CSS?

Kevin Cox picture Kevin Cox · Mar 11, 2013 · Viewed 47.8k times · Source

I have found that there is no float center in CSS and I was a little disappointed. However, I can't help but ask myself why. While many people want to use this for centering content I wished to use it to float a bunch of blocks into rows on a dynamic page size. Unfortunately without a float center it looks sloppy as there is extra space (whatever fraction of a full block doesn't fit) on one side. It makes me sad that the intended use of floats is hurt by this property missing.

I can't see a reason why there isn't a float center and was wondering if anyone had reasons, either technical or otherwise why a float center was not included in the standard.

Answer

Explosion Pills picture Explosion Pills · Mar 11, 2013

Instead of using float: left, use display: inline-block on the individual elements and center their container.

http://jsfiddle.net/ExplosionPIlls/rAkNY/5/