center content in div css in line code example
Example 1: css position element in the middle of a header
P.blocktext {
margin-left: auto;
margin-right: auto;
width: 200px;/*usually works best with a fixed width*/
}
Example 2: how to center horizontally and vertically block div
#html code
<div class="parent">
<h1 class="child">CSS is cool</h1>
</div>
#css code
.parent{
display:grid;
place-items:center;
width:560px;
height: 560px;
}