margin
JavaScript syntax:
margin
Values:
[ <length> | <percentage> | auto ]{1,4} | inherit
Initial value:
Not defined.
Applies to:
All elements.
Inherited:
No.
Percentages:
Refer to the width of the containing block.
Description:
margin shorthand property sets the width of the overall margin for an element or sets the widths of each individual side margin. Vertically adjacent margins of block-level elements are collapsed. The left and right margins of inline elements do not collapse. Negative margin values are permitted.
Examples:
<img id="myImg" src="http://java2s.com/Book/HTML-CSSImages/star.png" height="50" width="50" border="1">
<button onclick="myImg.style.margin='25 25 25 25'">25 Px Margin</button>
<button onclick="myImg.style.margin='0 0 0 0'">0 Margin</button>
h1 {margin: 2ex;}
p {margin: auto;}
img {margin: 10px;}
Home
HTML CSS Book
CSS Reference
HTML CSS Book
CSS Reference
Property:
- background
- background-attachment
- background-color
- background-image
- background-position
- background-repeat
- border
- border-bottom
- border-bottom-color
- border-bottom-style
- border-bottom-width
- border-color
- border-left
- border-left-color
- border-left-style
- border-left-width
- border-right
- border-right-color
- border-right-style
- border-right-width
- border-style
- border-top
- border-top-color
- border-top-style
- border-top-width
- border-width
- bottom
- clear
- clip
- color
- content
- counter-increment
- counter-reset
- cursor
- direction
- display
- float
- font
- font-family
- font-size
- font-style
- font-variant
- font-weight
- height
- left
- letter-spacing
- line-height
- list-style
- list-style-image
- list-style-position
- list-style-type
- margin
- margin-bottom
- margin-left
- margin-right
- margin-top
- max-height
- max-width
- min-height
- min-width
- outline
- outline-color
- outline-style
- outline-width
- overflow
- padding
- padding-bottom
- padding-left
- padding-right
- padding-top
- position
- quotes
- right
- text-align
- text-decoration
- text-indent
- text-transform
- top
- unicode-bidi
- vertical-align
- visibility
- white-space
- width
- word-spacing
- z-index
Related: