CSS-Margins
CSS margins are used to make room around an element. We can change the margin sizes for individual sides (top, right, bottom, left).
The following values can be assigned to margin properties:
- Length in cm, px, pt, etc... .
- The element's width as a percentage.
- The browser calculates the margin: auto.
- margin-top,margin-left,margin-right,margin-bottom: specifies margin for each side
Syntax
p {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
}
Margin Shorthand Property
All the margin property can be set in one line The syntax for it is given below:
margin: 25px 50px 75px 100px;
- top margin is 25px
- right margin is 50px
- bottom margin is 75px
- left margin is 100px