CSS – don’t write more than you need to

Let’s look at an example of when you might write more CSS than you need to:

Why is this more than you need? This is simply because you get the second line for free, once you have declared display:flex; the browsers CSS engine will now consider that element as a flex box, and by default it will come out of the box with flex-direction: row; see here

This is just one of many examples, so the point of this post is not to say “don’t use flex-direction: row; when you don’t need to!!!” the point is to start thinking about all your CSS and train your brain to identify redundancy.

Published
Categorized as CSS