padding is the space between the border and the content whereas margin is applied outside of the element to effect how far away it lies from other elements.
This is shown beautifully in the below schematic: