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:
- 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)