CSS Home

Margins and Padding in Cascading Style Sheets

Margins and padding are important concepts in CSS and are related to boxes. The most important thing to remember is that the margin is outside of the box while the padding is inside, between the box and its content.

margin: This specifies the margin between the outside of a box and the closest other elements on the page.

margin-bottom: This specifies the margin between the bottom of a box and the other elements below it on the page.

margin-left: This specifies the margin between the left side of a box and the other elements to the left of it on the page.

margin-right: This specifies the margin between the right side of a box and the other elements to the right of it on the page.

margin-top: This specifies the margin between the top of a box and the other elements above it on the page.

padding: This specifies the minimum space between an element and the border of the box containing it.

padding-bottom: This specifies the minimum space between the bottom of an element and the bottom border of the box containing it.

padding-left: This specifies the minimum space between the left side of an element and the left border of the box containing it.

padding-right: This specifies the minimum space between the left side of an element and the left border of the box containing it.

padding-top: This specifies the minimum space between the top of an element and the top border of the box containing it.

©2003 All Rights Reserved