In CSS, justify-content: center aligns items (such as text, divs or boxes) horizontally and align-items: center aligns things vertically. Both these CSS properties can be used by activating the display: flex property first.
.container {
display: flex;
justify-content: center;
align-items: center;
}
.red-box {
width: 200px;
height: 200px;
background-color: red;
}
These properties applies to the parent container. Here are the illustrations to explain the same :
![](https://mydevelopmentnotes.com/wp-content/uploads/2023/03/justify-content-center.jpg)
![](https://mydevelopmentnotes.com/wp-content/uploads/2023/03/align-items-center.jpg)