CSS PADDING & MARGIN

Syntax

All elements have a width and a height
Elements have a width of 100% of their parent and a height of 0
The height grows to match the content
Try not to set height attribute!
If the height attribute is lesser than the height of the content, the content will not appear
Unless specified, content stack on top of each other

Margin Shorthand

The margin CSS shorthand property allows you to set the margin area on all four sides of an element in one line!


Like a clock, the first value represents the top and the other values continue clockwise.
Each value is separated by a white space.


If only one value is specified: the value is applied to all four sides of the margin.


If only two values are specified: the first value is applied to the top and bottom; the second value is applied to the left and right.


If three values are specified: the first value applies to the top; the second value applies to the left and right; the third value applies to the bottom.

Return to previous page
Return to main page