THE PENDING DRAFT

How to Center in CSS

April 20, 2015

Let’s be honest. Centering in CSS can really suck! At least without the use of flexbox. “How to Center in CSS” is a neat little page i found today which helps you choose the right way of centering for different situations (known/unknown width and height, inline or block element etc.) and generates some code to accomplish what you need.

While i like the general idea of this, there are some things that should be improved and that would make it a lot more useful. First, the generated code uses inline-styles, which is just a terrible thing to teach to anyone. Displaying the generated styles in CSS (or even SCSS & CSS) would be a lot better. Second, it would be nice if it would promote the use of flexbox, too. Third, as with most things there are different ways to accomplish the same thing, so a little bit of background information on each technique and why it’s favored over another would be really great.

If you need to center something in CSS and are unsure about which technique to use, then i would still recommend this post on CSS-Tricks. I look it up frequently when i need to center anything, but i could also imagine such a generator to become a really useful tool.

CSS-Tricks – Centering in CSS: A Complete Guide

Leave your comment