Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vertical centering/aligning weakness

Status
Not open for further replies.

Leozack

MIS
Oct 25, 2002
867
GB
Would the statement "you cannot vertically align something unless it is a td cell" be correct? Basically all I wanted to do was verticall center some text in a box. But using vertical-align:middle on both the div box and the text span yields no results whatsoever. NOTHING I do makes anything vertically centered. So I'm about to give up on the whole css piles of blocks and stuff and just have the whole thing done in tables in a few minutes >> At least you can valign="midde" and it actually works ^^ Even if, so to speak, you need a table to do it just like css. I fail to see why css can say align:center but not valign:center. Who's bright idea was that? So far I'm using align="center" on the div tags too as css didn't want to work with even align:center.

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
It is true, vertical-align is one of the most mind baffling and strange attributes in css. It works on table cell and it works for aligning text and pictures when they both are inline. I have not seen it do a successful (and expected) job with anything else. Oh well, that's one of the blunders.
 
Leozack said:
I fail to see why css can say align:center but not valign:center. Who's bright idea was that?

That would be the W3C, then. You seem to misunderstand what vertical-align does. It is not intended to vertically centre one block level element inside another.

Here's what the W3C say. I've highlighted the relevant information:

W3C said:
This property affects the vertical positioning inside a line box of the boxes generated by an inline-level element. The following values only have meaning with respect to a parent inline-level element, or to a parent block-level element, if that element generates anonymous inline boxes; they have no effect if no such parent exists.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top