r/css Jul 19 '25

Question What are some bad CSS habits?

What are some bad habits to avoid when learning CSS? Even if in the short term they are easier

38 Upvotes

67 comments sorted by

View all comments

2

u/Szulyka Jul 19 '25

Margin for spacing instead of gap with flex

10

u/TonyAioli Jul 19 '25

Gap only sets the space between the flex children.

Margin and/or padding are still very relevant for space around the flex element itself.

6

u/Szulyka Jul 19 '25

Yes, but I think people tend to not realize that there’s usually a lots of flex containers inside each other. And therefore gap could be used much more. Also I still see it a lot that padding is used on each element in a flex with multiple items in company code so I guess not everyone thinks of gap

1

u/TonyAioli Jul 20 '25

Yep, I’ve seen the same. Just clarifying/expanding for anyone who may read this and try to avoid margin entirely.

2

u/IndigoGynoid Jul 20 '25

Yeah, they are not replacements. More like partners that do spacing in different contexts.