1
2
3
<div class="container">
<span>Lorem ipsum</span>
</div>

Absolute positioning + Transform

1
2
3
4
5
6
7
8
9
10
11
.container {
position: relative;
}

span {
display: inline-block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

Flexbox

1
2
3
4
5
.container {
display: flex;
justify-content: center;
align-items: center;
}

Grid

1
2
3
4
5
6
7
.container {
display: grid;
}

span {
margin: auto;
}