The CSS margin property is used to set the margin for an element. Its shorthand properties are following.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
div {
border: 10px solid lightblue;
}
div > p {
border: 1px dotted orange;
margin: 20px 50px 10px 30px;
}
</style>
</head>
<body>
<div>
<p>
This text has a different sized margin for each side. It is nested within a 'div' with a border to make it easier to see the effect of the margin.
</p>
</div>
</body>
</html>
Output
Example This text has a different sized margin for each side. It is nested within a 'div' with a border to make it easier to see the effect of the margin.
