CSS vertical alignment text inside li
Solution 1:
Define the parent with display: table
and the element itself with vertical-align: middle
and display: table-cell
.
Solution 2:
However many years late this response may be, anyone coming across this might just want to try
li {
display: flex;
flex-direction: row;
align-items: center;
}
Browser support for flexbox is far better than it was when @scottjoudry posted his response above, but you may still want to consider prefixing or other options if you're trying to support much older browsers. caniuse: flex
Solution 3:
line-height
is how you vertically align text. It is pretty standard and I don't consider it a "hack". Just add line-height: 100px
to your ul.catBlock li
and it will be fine.
In this case you may have to add it to ul.catBlock li a
instead since all of the text inside the li
is also inside of an a
. I have seen some weird things happen when you do this, so try both and see which one works.