Padding in Css covers the inside of the block element or structural element. Margins covers outside the block element or structural element. Thus, padding will put space between the elements in the block and the edge of the block. Margins puts space between each block.
Width is the content inside the box minus the margins, padding, and borders. Height is the content inside the box minus the margins, padding and borders.
The code for margins is
margin:value where value is in pixels or per cent.
margin:value | all four sides | value is in pixels or per cent |
margin-top:value | top margin only | value is in pixels or per cent |
margin-bottom:value | bottom margin only | value is in pixels or per cent |
margin-left:value | left margin only | value is in pixels or per cent |
margin-right:value | right margin only | value is in pixels or per cent |
margin:value value | vertical horizontal value |
value is in pixels or per cent auto can be used for horizontal |
margin:value value value | top sides bottom |
value is in pixels or per cent |
margin:value value value value | top right bottom left |
value is in pixels or percent |
padding:value | all four sides | value is in pixels or per cent |
padding-top:value | top only | value is in pixels or per cent |
padding-bottom:value | bottom only | value is in pixels or per cent |
padding-top:value | left only | value is in pixels or per cent |
padding_right:value | right only | value is in pixels or per cent |
padding:value value | vertical horizontal values | value is in pixels or per cent |
padding:value value value | top sides bottom | value is in pixels or per cent |
padding:value value value value | top right bottom left | value is in pixels or percent |
auto can be used for the horizontal value for margins. This will center the block.
Comments (0)