Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

padding
margin
css
vs

Padding vs. margin in CSS

Educative Answers Team
svg viewer
svg viewer
  1. Padding is the distance of the element from the elements inside it.
  1. Margin is the distance of the element from the adjacent elements.

Both of these properties are used to set up gaps on a page, but their methods are different.

  1. Padding creates the gap by either increasing its own size or ​decreasing the size of the contents inside it.
  1. Margin creates the gap by pushing adjacent elements away from it.
  1. Padding​ is used when the contents inside the container should not be touching the border of the container.
  1. Margin is used when the two elements should be separated enough that they don’t touch each other.
svg viewer
svg viewer
  1. Padding is used to increase the size of an element.
  1. Margin is used to bring an element to the center.

RELATED TAGS

padding
margin
css
vs
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring