Padding and Margin Cheatsheet


Margin

CSS Declaration CSS Declaration Block example How it changes the element
margin {margin: 100px} Changes the margin on all four sides to the same value
margin-top {margin-top: 100px} Changes the margin on top of element to the value listed
margin-right {margin-right: 100px} Changes the margin on right side of element to the value listed
margin-bottom {margin-bottom: 100px} Changes the margin on bottom side of element to the value listed
margin-left {margin-left: 100px} Changes the margin on left side of element to the value listed
margin {margin: 50px 100px 25px 75px} Changes the top margin to 50px, the right margin to 100px, the bottom margin to 25px, and the left margin to 75px
margin {margin: 50px 100px} Changes the margin on top and bottom margins to 50px and the left and right side margins to 100px

Helpful hint: think of changing margins as creating space outside of the element.


Padding

CSS Declaration CSS Declaration Block example How it changes the element
padding {padding: 100px} Changes the padding on all four sides to the same value
padding-top {padding-top: 100px} Changes the padding on top of element to the value listed
padding-right {padding-right: 100px} Changes the padding on right side of element to the value listed
padding-bottom {padding-bottom: 100px} Changes the padding on bottom side of element to the value listed
padding-left {padding-left: 100px} Changes the padding on left side of element to the value listed
padding {padding: 50px 100px 25px 75px} Changes the top padding to 50px, the right padding to 100px, the bottom padding to 25px, and the left padding to 75px
padding {padding: 50px 100px} Changes the padding on top and bottom padding to 50px and the left and right side padding to 100px

Helpful hint: think of changing padding as constricting space inside the element.