473,416 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

XHTML/CSS Standard Vertical Centering sought

Okay, I've been scouring Google for hours looking for a solution to this
problem, but as of yet I can't find one.

XHTML Transitional seems to specify that I can no longer set a table's
height to 100% and vertically center content inside of it. Therefore,
I'm seeking a way, preferably in CSS to vertically center a site.

Here's more of a visual to what I have:

/********************************
/ (header area)
/********************************
/* * * *
/* * content * *
/* * (420px,flexible * *
/* * dep. on content) * *
/* * * *
/********************************
/ (footer area)
/********************************

The content area is what needs to be centered. Ideally, the content is
420px tall, but that may vary according to the amount of content, so
using a margin-top: -210px, option wouldn't work, nor would percentages,
so far as I can tell.

If there was a way to do it in pre-XHTML with tables, I can't believe
that it's impossible to do in XHTML.

Thanks in advance for any feedback!
Kenneth
Jul 21 '05 #1
1 7880
Kenneth <ke*****@NOPSAMpardue.com> wrote:
XHTML Transitional seems to specify that I can no longer set a
table's height to 100% and vertically center content inside of it.
"No longer"? A height attribute was never part of any HTML specification.
And IE stopped recognizing it in version 6, unless it decides, by doctype
sniffing absurdity, that the author "wants" IE to work in quirks mode.
This happens no matter whether the document purports to use classic HTML
or XHTML.

And you can set a table's height in CSS:

<style type="text/css">
html, body, table { height: 100%; margin: 0; padding: 0; }
td { vertical-align: middle; }
</style>

<table border><tr><td>
<p>Hello world</p>
</td></tr></table>
Here's more of a visual to what I have:
Regarding vertical layout, this is probably what you want:

<style type="text/css">
html, body, table { height: 100%; margin: 0; padding: 0; }
td { vertical-align: middle; }
td.header { vertical-align: top; }
td.footer { vertical-align: bottom; }
</style>
</head>
<table>
<tr><td class="header">header area</td></tr>
<tr><td>
<p>Hello world</p>
</td></tr>
<tr><td class="footer">footer area</td></tr>
</table>

Of course, it's not much better than doing table layout in (X)HTML.

The tricky part is that vertical-align is defined as vertical alignment
of content for table cells only. And although "table cell" is here a CSS
concept in principle, so that you could turn e.g. a <div> element into a
table cell by declaring display: table-cell, this won't work on the WWW -
IE does not support table-cell.

For other elements, vertical-align is vertical alignment of text lines
and wouldn't help here.
If there was a way to do it in pre-XHTML with tables, I can't believe
that it's impossible to do in XHTML.


What made you think you need to use XHTML at all?

But there are lots of different ways of centering vertically in CSS,
whether you use classic HTML or XHTML, each with various drawbacks.
See the links at the end of
http://css-discuss.incutio.com/?page...ngBlockElement

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Wayfarer | last post by:
I *HAVE* Googled the hell out of it, but there's nothing I can understand (in words of one syllable or less) that works for me. If you go to http://www.journeys.ws/layout.html, on the...
7
by: Bill | last post by:
Hi Browser IE6 I have the following doctype xhtml strict <div id="logoboxwww.testers.com</div> #logobox {
2
by: Warren Sarle | last post by:
See http://www.w3.org/Style/Examples/007/center-example.html When I view this page in IE6 (with all current updates on Windows XP), it is not vertically centered as the page itself claims and as...
5
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
4
by: Narven | last post by:
Hi, I've been creating a script that dynamic loads js files. but after creating that script, (and i use document.createElement('script');) in that function.. i've realise that the code that...
10
by: Saqib Ali | last post by:
Recently I have been trying to find a web designer that can follow the W3C HTML/XHTML. We need a website for a non-profit re-designed and upgraded to conform to W3c HTML/XHTML and usability...
1
by: Jeff | last post by:
ASP.NET 2.0 The code below doesn't vertically center the image within the div, what am I missing?? <div style="background-color:Green; width:210px; height:230px; text-align:center;...
3
by: Garr | last post by:
I have a page I'm working on that I need to get some text centered between the top and bottom of an image. The page is XHTML and CSS valid. The URL is http://seraphim.garrmusic.com/members.php ...
1
by: vingomail | last post by:
Hi friend I want the updatepanel progress bar to be displyed at absolute center of the page(Horizontal-vertcal centering). It should be done at unknown height and width. Also It should display...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.