Definition:
CSS margin: inherit value inherit the margin with its parent elements.
Syntax:
margin:inherit;
Source Code:
<!DOCTYPE html>
<html>
<head>
<style>
.title{
text-align:center;
}
.paragraph{
border: 2px dashed red;
background-color: orange;
text-align:center;
margin: 40px;
}
.paragraph-inherit{
border: 2px dashed red;
background-color: pink;
text-align:center;
margin: inherit;
}
</style>
</head>
<body>
<div class="title"> <b>See the different between margin with pixel and inherit.</b> </div>
<div class="paragraph">This is a paragraph with margin:40px;. </div>
<div class="paragraph-inherit">This is a paragraph with margin:inherit property value. </div>
</body>
</html>
Output:
Donate to support writers
You may be interested in the following topics:
- CSS margin:collapse;
- CSS margin:inherit;
- CSS Margin: auto;
- CSS margin-left
- CSS margin-bottom
- CSS margin-right
- CSS Margin-top
- CSS Margin
- CSS Margin (All Properties)