Centering text vertically using CSS
Published
This is the easiest and best way to center text vertically, simply set the line-height
to the same value as height
. Remember that in order to modify the height
of an element, it needs to be displayed as either a block
or inline-block
.
See the Pen Vertically centered text by Daniel Imms (@Tyriar) on CodePen
div.centered-box
{
height:70px;
line-height:70px;
border:5px solid #000;
}