What is the difference between margin and padding in CSS?
I'm trying to understand the difference between margin and padding in CSS, as both seem to create space around elements but behave differently. I’d like to know how each one affects element layout and spacing, and when to use one over the other. What’s the main distinction between margin and padding in CSS?