What is difference between CSS margin and padding?

This question already has an answer here:

  • When to use margin vs padding in CSS [closed] 18 answers

  • In short padding make "space" inside your box, and margin do this outside of your box.

    This picture explain it pretty good :)

    在这里输入图像描述


    The simple way to look at it is that padding is internal to the border of the content (pad from the inner edge of the line), and margins are external to the border of the content (pad from the outside edge of the line).

    Add a border to your content pane in 5px solid black and see the difference in text and border positioning on the page as you change the padding and margin values.

    链接地址: http://www.djcxy.com/p/29418.html

    上一篇: 什么是填充在CSS和HTML上的作用

    下一篇: CSS边距和填充有什么区别?