Control icon size with font-size

A quick 🔥 CSS tip:

If you set your SVG icon’s width and height to 1em, you can then contextually size it with font-size.

It also means that your icon will always be predictably sized by default.

Update: Thanks to @fvsch’s excellent suggestion, I’ve created a fork that sets the width and height on the SVG itself:

Hi 👋
I’m Andy, a freelance web designer

I’m not currently booking new projects, but you can support my work by buying “Every Layout”.

Buy Every Layout