0

Difference between padding and margin

Pls, Can anyone explain the difference between padding and margin in html

19th Jan 2023, 10:22 PM
Ayodeji Akinyele
Ayodeji Akinyele - avatar
8 Antworten
+ 9
padding-> inside margin -> outside https://www.w3schools.com/css/css_boxmodel.asp
19th Jan 2023, 11:59 PM
Bob_Li
Bob_Li - avatar
+ 12
padding makes space between a content and the border of an element inside it. Margin makes space between other elements on the webpage.
19th Jan 2023, 10:25 PM
Lamron
Lamron - avatar
+ 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.
20th Jan 2023, 12:51 AM
Sam
+ 3
Sammy Raven I like your answer to clarify to those not as savvy (ie me) what is DOM. Will you edit your answer. :-)
20th Jan 2023, 1:18 AM
William Owens
William Owens - avatar
+ 2
William Owens post updated
20th Jan 2023, 1:35 AM
Sam
+ 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
21st Jan 2023, 1:18 PM
Zeeshan Khan
Zeeshan Khan - avatar
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
21st Jan 2023, 2:43 PM
Mawuena Kossi Baboh
Mawuena Kossi Baboh - avatar
0
Mourad
21st Jan 2023, 8:04 PM
Mourad Benali
Mourad Benali - avatar