contact@codebetter.in 8823075444
9993928766
  • Tutorials Home
  • Contact

What is the difference between padding and margin in CSS?

Sr.No. Margin Padding
1. The outer space of an element i.e. margin is the space outside the border. The inner space of an element i.e.padding is space inside the element’s border.
2. It can be negative or any float number. It does not allow negative values.
3. We can set the margin to auto. We cannot set the padding to auto.
4. Styling of an element such as background color does not affect the margin. Padding is affected by the styling of an element, such as background color.