How can I center one div in the middle of the screen? Mainly I have problems with horizontal centering. If I use absolute positioning, then only the first line is in the middle horizontally. My code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>hey I am a title</title>
<style>
html, body {width: 100%; height: 100%;}
.t7{
text-align: center;
position: relative; top: 50%;}
</style>
</head>
<body>
<!-- this code centers an element in the middle of the screen -->
<div class="t7">
I am a text in the middle of the screen.
<br>
second line
<br>
third line
<br>
fourth line
<br>
fifth line
</div>
</body>
</html>
Thank you.