how to center align a div css code example
Example 1: center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: css align center
//HTML
<div class="parent">
<span>Hello World</span>
</div>
//CSS
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 3: center css elements
body{
display: grid;
place-items: center;
}
Example 4: how to center a div
<div class="container">
<div class="child"></div>
</div>