CSS margin-right Property

Description

The margin-right property of an element sets the margin space required on the right of an element. A negative value is also allowed.

Initial value
0
Applies to
All elements
Inherited
No
Media
Visual
Computed value
As specified, but with relative lengths converted into absolute pixel values.
Animatable
Yes
CSS Version
CSS1, CSS2, CSS3
JavaScript syntax
object.style.marginRight

Syntax

margin-right: <length> | <percentage> | auto

Values

  • <length>Specifies a fixed length, using any standard CSS length units. Negative Values are allowed.
  • <percentage>A percentage always relative to the width of the containing block.
  • inherit

Example

.class {
  margin-top: 1em;
  margin-right: 2em;
  margin-bottom: 3em;
  margin-left: 2em;
}

Give it a Try

Click the button below to experiment with this property.

Give it a Try!

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
312113.51
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
118410.11X