HTML DOM marginRight Property
Complete Style Object Reference
Definition and Usage
The marginRight property sets the right margin of an element.
Syntax
Object.style.marginRight=auto|length|%
|
Possible Values
Value |
Description |
auto |
The browser sets a right margin |
length |
Defines a fixed right margin |
% |
Defines a right margin in % of the total width of the
document |
Example
The following example changes the right margin of a paragraph:
<html>
<head>
<style type="text/css">
p
{
text-align: right
}
</style>
<script type="text/javascript">
function changeMargin()
{
document.getElementById("p1").style.marginRight="32px";
}
</script>
</head>
<body>
<input type="button" onclick="changeMargin()"
value="Change the right margin of a paragraph" />
<p>This is a paragraph</p>
<p id="p1">This is a paragraph</p>
<p>This is a paragraph</p>
</body>
</html>
|
Try-It-Yourself Demos
marginRight - Change the right margin of a paragraph
Complete Style Object Reference
 |

|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|