//1
<body>
<div class="div1"></div>
</body>
<style>
.div1 {
width: 200px;
height: 200px;
background: pink;
position: absolute;
top: 50%;
left: 50%;
margin-left: -100px;
margin-top: -100px;
}
</style>
//2
<body>
<div class="div2"></div>
</body>
<style>
.div2 {
background: pink;
width: 100px;
height: 100px;
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
//3
<body>
<div class="div3"></div>
</body>
<style>
.div3 {
background: pink;
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50px, -50px)
}
</style>
//4
<body>
<div class="div4"></div>
</body>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 600px;
}
.div4 {
background: pink;
width: 100px;
height: 100px;
}
</style>