You are here: Reference > JavaScript > client-side > HTML DOM > properties > rightMargin (body)

rightMargin property (body)

Browser support:
Sets or retrieves the right margin for the document body in pixels.
This property is deprecated. Use the marginRight style property instead.

Syntax:

object.rightMargin;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: rightMargin

Possible values:

String that sets or retrieves the width of the margin, with an integer optionally followed by a 'px' (pixel) unit designator.
Default: 10.

Example HTML code 1:

This example illustrates the use of the rightMargin attribute:
<body rightmargin="100px">
    RightMargin=100px
</body>
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<body style="margin-right:100px; text-align:right;">
    The right margin is 100px
</body>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the rightMargin property:
<head>
    <script type="text/javascript">
        function SetRightMargin () {
            var input = document.getElementById ("myInput");

            if ('rightMargin' in document.body) {
                document.body.rightMargin = input.value;
            } else {
                alert ("Your browser doesn't support this example!");
            }
        }
    </script>
</head>
<body rightmargin="100px">
    <input id="myInput" type="text" value="40" />
    <button onclick="SetRightMargin ();">Set rightMargin!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content