Easy Tutorial
❮ Prop Fileupload Name Prop Img Hspace ❯

Style marginRight Property


Definition and Usage

The marginRight property sets or returns the right margin of an element.

Syntax

Set the marginRight property:

Return the marginRight property:

Value Description
% Defines the right margin as a percentage of the width of the parent element.
length Defines the width of the right margin using units like px, cm, etc.
auto The browser sets the right margin.
inherit The right margin is inherited from the parent element.

Browser Support

All major browsers support the marginRight property.

Note: IE7 and earlier versions do not support the "inherit" value. IE8 requires a !DOCTYPE to support "inherit". IE9 supports "inherit".


Tips and Notes

Both the margin and padding properties insert space around an element. However, the difference is that margin inserts space outside the border, while padding inserts space inside the border.


Example

Change the right margin of a div element:

❮ Prop Fileupload Name Prop Img Hspace ❯