Vertical centering of text

liunx

Guest
Is there any simple way to position a text into middle of the screen or layer? A number of HTML objects support horizontal alignment, but apart from table nothing seems to support vertical alignment. I have read in a book that <span> supports vertical-align style, but I could never get it to work.

Any advice would be greatly appreciated.Could you show us some of the coding that you've tried?

I'd think that placing the span inside a div would work--have you tried that yet?
Also make sure you're using middle with the vertical-align attribute.. Sometimes people use center, which is wrong..This is a <span> that I tried, which works in all respects except for the vertical-align property:

<span id=aaa style='POSITION: absolute; TOP: 0px; LEFT: 0px; WIDTH: 100%; HEIGHT: 100%; TEXT-ALIGN: CENTER; vertical-align: bottom'>Message</span>I have a motto: If at first you don't succeed, cheat.

In other words, just slap a single cell table into your page and use that to align vertically. Sure it will not validate, but no end-user or browser cares a damn about how valid your (X)HTML is anyway.Vertical-align, except when used in a table-cell, only aligns the object relative to the line box, not the block box.

<!-- m --><a class="postlink" href="http://www.dynamicsitesolutions.com/css/vertically_centering_elements/">http://www.dynamicsitesolutions.com/css ... _elements/</a><!-- m -->
 
Back
Top