CSS margin-left property
CSS Margin-left Property
Description
The margin-left property sets the width of the margin on the left side of an element.
Possible Values
- length – Any length value.
-
percentage – The margin width is calculated relative to the width of the element’s containing block.
-
auto – By default, let the browser automatically set margins.
Applies to
All HTML elements.
DOM syntax
object.style.marginLeft = "5px"
Example
This is an example –
<html>
<head>
</head>
<body>
<p style = "margin-left: 15px; border:1px solid black;">
This is a paragraph with a specified left margin
</p>
<p style = "margin-left: 5%; border:1px solid black;">
This is another paragraph with a specified top margin in percent
</p>
</body>
</html>
This will produce the following −