Style margin Property
Style margin Property
The margin property is used to either set or return the margin of an element border. It has the following types:-
- One value specifies the margin for all four sides.
- Two values will specify one margin for top and bottom margins and the other margin for left and right margins.
- Three values will specify the first margin for the top margin, a second margin for the left and right margins, and a third margin for the bottom margin.
- Four values will specify the margin for all four sides from the top, right, bottom, and left sides of the margins.
Syntax:-
Its syntax is:- object.style.margin OR object.style.margin = % | length | auto | initial | inherit
Return:-
Its return is:- string having a margin of an element
Further Explanation:-
Value | Description |
---|---|
% | Defines margins in % of width of parent element. |
length | Defines margins in length units. |
auto | The browser sets margins. |
initial | Sets property to its default value. |
inherit | Inherits property from its parent element. |