By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,766 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,766 IT Pros & Developers. It's quick & easy.

XHTML - centering a table?

P: n/a
hello,

i see that <table align="center"is no longer valid markup in XHTML.
nor is <center><table></table></center>.

how then does one center a table?

found articles for centering text:

http://msconline.maconstate.edu/Tuto...xhtml03-03.htm

....but that doesnt help on a table because i dont want the text
*inside* the table centered, only the table itself.
surely this most be a common task?
thanks!
sm
Feb 14 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Feb 14, 1:31*pm, SpaceMarine <spacemar...@mailinator.comwrote:
hello,

i see that <table align="center"is no longer valid markup in XHTML.
nor is <center><table></table></center>.

how then does one center a table?
Set the left and right margins of the table to "auto" in your style
sheet.

Nick

--
Nick Theodorakis
ni**************@hotmail.com
contact form:
http://theodorakis.net/contact.html
Feb 14 '08 #2

P: n/a
Nick Theodorakis wrote:
On Feb 14, 1:31 pm, SpaceMarine <spacemar...@mailinator.comwrote:
>hello,

i see that <table align="center"is no longer valid markup in XHTML.
nor is <center><table></table></center>.

how then does one center a table?

Set the left and right margins of the table to "auto" in your style
sheet.
Which will not work with older versions of IE still being used, so you
may have to handle that.
Feb 14 '08 #3

P: n/a
Scripsit SpaceMarine:
i see that <table align="center"is no longer valid markup in XHTML.
It is.
nor is <center><table></table></center>.
It is.

You don't really know what XHTML is, do you? Don't worry, most other
authors who use XHTML don't know that either. But you might draw the
conclusions and upgrade to HTML 4.01, which is far better supported by
current browsers.
how then does one center a table?
There are ways to do that in CSS (consider checking the FAQs), but why
bother, if you already know the HTML way?
surely this most be a common task?
It's not. Why would you want to center a table?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 14 '08 #4

P: n/a
On Feb 14, 2:20*pm, C A Upsdell <cupsd...@upsdell.invalidwrote:
Nick Theodorakis wrote:
On Feb 14, 1:31 pm, SpaceMarine <spacemar...@mailinator.comwrote:
hello,
i see that <table align="center"is no longer valid markup in XHTML.
nor is <center><table></table></center>.
how then does one center a table?
Set the left and right margins of the table to "auto" in your style
sheet.

Which will not work with older versions of IE still being used, so you
may have to handle that.
It'll work with IE down to version 6 as long as standards mode is
invoked (and it needs to be invoked even to get it work with IE7). If
the OP wants to make it work with IE5 (and even Netscape 4) I still
have my old table centering page up:

<http://theodorakis.net/tablecentertest.html>

Although I felt a little hesitant to plug it in my other post.

Nick

--
Nick Theodorakis
ni**************@hotmail.com
contact form:
http://theodorakis.net/contact.html
Feb 14 '08 #5

P: n/a
On Feb 14, 2:09 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
Scripsit SpaceMarine:
i see that <table align="center"is no longer valid markup in XHTML.

It is.
nor is <center><table></table></center>.

It is.
not according to my XHTML 1.0 Transitional validation tool (Visual
Studio 2005) -- "...is considered outdated. A newer construct is
recommended."

There are ways to do that in CSS (consider checking the FAQs),
im asking here.

surely this most be a common task?

It's not. Why would you want to center a table?
who are you to question why i want to center a table?

are you always such a useless fart-bubble twit? or just online?
sm
Feb 14 '08 #6

P: n/a
On Feb 14, 3:37 pm, Nick Theodorakis <nick.theodora...@gmail.com>
wrote:
It'll work with IE down to version 6 as long as standards mode is
invoked (and it needs to be invoked even to get it work with IE7). If
the OP wants to make it work with IE5 (and even Netscape 4) I still
have my old table centering page up:

<http://theodorakis.net/tablecentertest.html>
very useful, thanks nick.

sm
Feb 15 '08 #7

P: n/a
On Feb 14, 2:09 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
There are ways to do that in CSS (consider checking the FAQs), but why
bother, if you already know the HTML way?
ps, Twit Master 3000 -- it is better to define layout in CSS over HTML
anyway, as it lets the style doc render the content dynamically based
on what the current medium is. for instance, my project uses one set
of CSS docs for web browsers, and another for handhelds. prefer not to
"hard code" the alignments in HTML even if they were standards-
compliant tags, which i dont think they are any longer (see above).

but, i found my solution, thanks to nick. im outtie. ta!
sm
Feb 15 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.