CSS margin-right Property

Set the right margin for a <p> element:

p  {
margin-right: 2cm;
}

Try it Yourself »


Definition and Usage

The margin-right property sets the right margin of an element.

Note: Negative values are allowed.

Default value: 0
Inherited: no
Animatable: yes, see individual propertiesRead about animatable – Try it
Version: CSS1
JavaScript syntax: object.style.marginRight=”100px” Try it
CSS Syntax
margin-right: length|auto|initial|inherit;
Property Values
Value Description
length Specifies a fixed right margin in px, pt, cm, etc. Default value is 0px
% Specifies a right margin in percent of the width of the containing element
auto The browser calculates a right margin
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

Post Author: Zahid Farid