CSS Margins

Margin properties allow you to set the width of the margin around the element box. Since margins are outside the element box, the background color or image for the page or parent element is what will show through the margin.

Margins

Property

Description

Values

Sample Code

margin

Sets all of the margin properties of an element from one to four values

length
percentage
auto

h1 {margin: 4px}

h2{margin:2 1 3 3px}

margin-bottom

Sets bottom margin

length
percentage
auto

h1 {margin-bottom: 2em}

margin-left

Sets left margin

length
percentage
auto

h1 {margin-left: 2px}

margin-right

Sets right margin

length
percentage
auto

h1 {margin-right: 10.5%}

margin-top

Sets top margin

length
percentage
auto

h1 {margin-top: 2em}

Samples

Result:

NO MARGINS


WITH MARGINS




This website is hosted for free by Freewebs.com - free website. Get your own Free Website now!