CSS margin
The CSS margin property is shorthand for specifying margin width on all sides of an element. It is classed as "shorthand" because it sets the margin-top, margin-right, margin-bottom and margin-left properties all in one place.
| Syntax: |
margin: <value1> <value2> ...;
|
| Possible Values: |
- <margin-width> (specify one for each side, or 1 for all)
- inherit
|
| Initial Value: |
not defined
|
| Applies to: |
All elements
|
| Inherited: |
No
|
| Media: |
Visual
|
| Example: |
margin:10px;
- All four sides have a margin of 10 pixels.
margin:10px 20px;
- Top and bottom have a margin of 10 pixels.
- Right and left have a margin of 20 pixels.
margin:10px 20px 30px;
- Top is 10px
- Left and right are 20px
- Bottom is 30px
margin:10px 20px 30px 40px;
- Top is 10px
- Right is 20px
- Bottom is 30px
- Left is 40px
|
| Try it yourself! |
|
Enjoy this page?
-
- Link to this page (copy/paste into your own website or blog):
- Link to Quackit using one of these banner ads.
Thanks for supporting Quackit!