0
Difference between padding and margin
Pls, Can anyone explain the difference between padding and margin in html
8 Answers
+ 9
padding-> inside
margin -> outside
https://www.w3schools.com/css/css_boxmodel.asp
+ 12
padding makes space between a content and the border of an element inside it.
Margin makes space between other elements on the webpage.
+ 6
Browsers use the "box model" to represent the size of DOM* objects in the viewport.
The layers of a box from outside to inside are: margin -> border -> padding -> content.
These layers have X (width, left to right) and Y (height, top to bottom) properties. Margin is the space between DOM elements; border is the space outside but attached to the DOM element; padding is the non-content space inside the DOM element; the content is what the DOM element contains.
*DOM: document object model. The idea that all elements of a web document can be described as nodes in a tree of objects. Each html tag represents an object node in that tree.
+ 3
Sammy Raven I like your answer to clarify to those not as savvy (ie me) what is DOM. Will you edit your answer. :-)
+ 2
William Owens post updated
+ 2
margin:- the margin of an element represents the outside space of the element itself
padding:- while the padding represents the inner space surrounding the element
0
padding is the space between the content and the border of the box and the margin is the space between the border of the box and other elements. You can consider yourself as the content, your dress as the padding and the space between you and other peoples as the margin
0
Mourad