Tuesday, April 28, 2009

CSS: Center Aligning Text Vertically - Method 3

Another approach to vertically centering text is to change the display property of the container to table-cell and add the vertical-align property with the value middle. This method does not work with MS Internet Explorer.

Example

div#header {
vertical-align: middle;
display: table-cell;
height: 200px;
background-color: yellow;
}

<div>
My text
</div>

No comments:

Post a Comment