Valign body.

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Valign body.

Post by JellyFish »

Hi, I tried:

Code: Select all

<body valign="middle">
...
And it didn't vertically align all the content within the body tags. How would I do this?

Thanks for reading. All help is appreciated.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Vertical centering is a much-sought-after thing. Google will have lots of info on the subject.

Short answer: only table cells support this behaviour, but it can be emulated.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Thanks Kieran. So I'd guess I could just wrap my content within a table. Or is there another way?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

ug.. I'd never suggest that! Google it up - there are a zillion solutions for "vertical centering"
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

I got a result that says to set the body's display property to table-cell and then use the vertical-align property. Is this recommened?

EDIT: Wait, that didn't work.

EDIT 2: All of the information that I've been getting from google are saying the same thing. That is to wrap something around the content in the body, div mostly.

Why wouldn't you suggest using a table? Would a div be better?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

the gods of web development hate table-based layouts!
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Table layouts are evil - I'd use javascript first.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Kieran Huggins wrote:Table layouts are evil - I'd use javascript first.
don't think I'd go that far... I still use a table for layout every once in a blue moon for those clients who just want it done cheap and fast.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Daedalus- wrote:the gods of web development hate table-based layouts!
Why? I love them.
Table layouts are evil - I'd use javascript first.
Is that the only reason I shouldn't use them, cause if so it doesn't convince me... :D
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

http://www.google.com/search?q=css+desi ... out+tables
Tables aren't meant for site layout. They're meant for data layout.

oh yea... this too:
http://www.csszengarden.com

If you want to be considered professional in any way, design without tables.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Tables are for tabular data display, not marking up your document. There are a bunch of methods than can be used to center a div on the screen. I would look at A List Apart for some helpful topics, or google search for 'vertical alignment of content in div'.

PS There is nothing than cannot be designed with proper CSS than can be built with tables. And never turn to tables for layout. Never. you can seriously knock out a CSS layout just as fast as a table-based layout, without all the cruft.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Everah wrote:you can seriously knock out a CSS layout just as fast as a table-based layout, without all the cruft.
Cruft? Honestly I don't see why not. It works good and I'm not really interested in a title (professional).
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

How about accessibility?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

It wouldn't be that hard if the table wasn't to complex.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

JellyFish wrote:
Everah wrote:you can seriously knock out a CSS layout just as fast as a table-based layout, without all the cruft.
Cruft? Honestly I don't see why not. It works good and I'm not really interested in a title (professional).
If not accessibility, why are you not interested in semantic development? Or the actual readable mark up document? Sure, tables are the easiest thing to use (when you are not a professional designer), they are simply not the best, or intended, tool to use.
Post Reply