Thursday, 21 June 2012

Centering text vertically using CSS

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.


Centered text

div.centered-box
{
  height:70px;
  line-height:70px;

  border:5px solid #000;
}