spatara
spatara

Reputation: 901

css vertically center text

I am inputting this in w3school's tester and I can't figure out how to vertically align the text. vertical-align:middle; doesn't help.

<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
a
{
display:block;
width:100px;
height:30px;
margin:5px;
background-color:#66CC33;
text-decoration:none; color:#000;
text-align:center;
font-family:"Verdana",Times,serif;
vertical-align:middle;
}
</style>
</head>

<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>

</body>
</html>

Upvotes: 0

Views: 169

Answers (2)

ExCluSiv3
ExCluSiv3

Reputation: 184

li {
padding-right: 80px;
padding-top: 25px; /*could be bottom depens on what you prefer to do.*/
}

I guess this work, if the px not match play with them see what you can do.

Don't forget confirm or vote up.

Upvotes: 0

Explosion Pills
Explosion Pills

Reputation: 191809

Set the line-height equal to the height (30px).

http://jsfiddle.net/9Gr9S/

Upvotes: 5

Related Questions