I would want to centre the li element in ul vertically. I've tried using text-align:center but it didn't work. I've been searching for a solution but it doesn't work. I'd also want an explanation to the solution because I'm relatively new to css.
/*Default styling*/
* {
margin: 0;
padding: 0;
}
/*Links section*/
.links {
background-color: coral;
width:100%;
height:40px;
}
.links ul {
}
.links li {
margin: auto;
display:inline-block;
text-align:center;
height:100%;
padding: 0 20px;
font-family:Arial, Helvetica, sans-serif;
}
.links li:hover {
background-color: red;
width:auto;
}
<!DOCTYPE html>
<html>
<head>
<link href="./style.css" type="text/css" rel="stylesheet">
<title>Beans testing AREA</title>
</head>
<body>
<ul class="links">
<li>
Home
</li>
<li>
About
</li>
<li>
Life
</li>
</ul>
</body>
</html>