O
32

Hot take: I just realized most CSS tutorials skip the part about inheritance

Tbh I was messing around with a personal project last weekend and finally dug into why my font sizes kept acting weird. Found a random MDN page that broke down how CSS inheritance actually flows through the DOM tree. Turns out like 70% of properties inherit by default but nobody ever told me that in any beginner course I took. I spent like 2 hours just testing it on a simple card layout and it explained so many 'bugs' I'd run into before. Has anyone else had that moment where a basic concept just never got explained properly?
1 comments

Log in to join the discussion

Log In
1 Comment
mason_flores21
And I remember hearing on a dev podcast once that the key thing to learn about inheritance is that it's mostly font and text properties that pass down by default (makes sense when you think about it). They said color, font-family, and line-height are the big ones that inherit, but things like margins and padding don't (which explains a lot of my old mistakes honestly). Once I started checking MDN's "inherited: yes/no" line on every property I use, my layouts stopped breaking in those weird unexpected ways.
6