CSS Margin: auto;

Please Share On:

Definition:

CSS margin: auto value applies to set the margin property automatically to the horizontal center within the elements.

Syntax:

margin:auto;

Source Code:

<!DOCTYPE html>
<html>
  <head>
    <style>
      .paragraph{
        width: 200px;
        border: 2px dashed red;
        background-color: pink;
        text-align:center;
        margin: auto;
      }
    </style>
  </head>

  <body>
    <div class="paragraph">Margin property value is auto. </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