CSS margin:inherit;

Please Share On:

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:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial