473,320 Members | 1,952 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,320 software developers and data experts.

Whats the new way to center a table

Hi,

I have read the you should no longer use 'align="center"' when you
want to center a table or something other.
So I asked myself what should I use than. I found something that you
should use styles. But they used a attribute that is only for text
elements.
So can someone give me an example or an url where I can find further
information.

I first discovered this problem while testing my application with
Mozilla 1.3.1. The align=center for my tables had no effect. When I
put the table in a <div align=center> than all works fine.

cu
Bjoern
Jul 20 '05 #1
9 10672
Bjoern Wolfgardt <14*************************@posting.google.com> wrote in
comp.infosystems.www.authoring.html:
I have read the you should no longer use 'align="center"' when you
want to center a table or something other.
So I asked myself what should I use than. I found something that you
should use styles. But they used a attribute that is only for text
elements.
So can someone give me an example or an url where I can find further
information.


http://stone.thecoreworlds.net/www/centre/

Regards,
Geoff

--
http://www.allmyfaqs.com/faq.pl?Geoff_Ball
http://www.allmyfaqs.com/faq.pl?Web_Core_References
http://www.allmyfaqs.com/faq.pl?How_to_post
Jul 20 '05 #2
In article <14*************************@posting.google.com> in
comp.infosystems.www.authoring.html, Bjoern Wolfgardt
<aa*****@gmx.de> wrote:
can someone give me an example or an url where I can find further
information.


http://theodorakis.net/tablecentertest.html

It's the goods!

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #3
Stan Brown <th************@fastmail.fm> wrote:
http://stone.thecoreworlds.net/www/centre/


That's a lovely resource, but it doesn't actually answer the
question. :-(


It does, but this is a question that cannot be answered in
straightforward way as it depends on a number of variables (doctype,
<IE6 etc.>.

The page answers the question by explaining how it works in the "Teach a
man to fish" tradition.
Headless

Jul 20 '05 #4
LOL...

Web development is so confusing.

The CSS Way works fine with Mozilla. But not with IE 6. And Mozilla
doesn't use the align=center attribute but IE 6 does.

I think I will use both like this:
<table align=center style="MARGIN-LEFT:auto;MARGIN-RIGHT:auto"
border="1">

cu
Bjoern Wolfgardt

Stan Brown <th************@fastmail.fm> wrote in message news:<MP************************@news.odyssey.net> ...
In article <14*************************@posting.google.com> in
comp.infosystems.www.authoring.html, Bjoern Wolfgardt
<aa*****@gmx.de> wrote:
can someone give me an example or an url where I can find further
information.


http://theodorakis.net/tablecentertest.html

It's the goods!

Jul 20 '05 #5
Stan Brown wrote:
In article <1234666.PYKUYFuaPT@geoffball> in
comp.infosystems.www.authoring.html, Geoff Ball <ge********@shaw.ca>
wrote:
http://stone.thecoreworlds.net/www/centre/


That's a lovely resource, but it doesn't actually answer the
question. :-(


Really?

Quote:
Block level content includes such elements as <h1>, <h2>, <p>, <table> (but
^^^^^
see IE Bugs), and <div>. To centre block level elements...

--
David Dorward http://david.us-lot.org/
Jul 20 '05 #6
Bjoern Wolfgardt wrote:

Please direct your attention to: http://www.allmyfaqs.com/faq.pl?How_to_post
The CSS Way works fine with Mozilla. But not with IE 6. And Mozilla
doesn't use the align=center attribute but IE 6 does. I think I will use both like this:
<table align=center style="MARGIN-LEFT:auto;MARGIN-RIGHT:auto"
border="1">


MSIE is broken. You have to force it in to standards mode or take further
steps to centre block level content in it. See:
http://david.us-lot.org/www/centre/#ie

--
David Dorward http://david.us-lot.org/
Jul 20 '05 #7
In article <bf*******************@news.demon.co.uk> in
comp.infosystems.www.authoring.html, David Dorward
<do*****@yahoo.com> wrote:
Stan Brown wrote:
In article <1234666.PYKUYFuaPT@geoffball> in
comp.infosystems.www.authoring.html, Geoff Ball <ge********@shaw.ca>
wrote:
http://stone.thecoreworlds.net/www/centre/


That's a lovely resource, but it doesn't actually answer the
question. :-(


Really?

Quote:
Block level content includes such elements as <h1>, <h2>, <p>, <table> (but
^^^^^
see IE Bugs), and <div>. To centre block level elements...


My apologies. I overlooked that.

I think Nick Theodorakis' page is much better for the OP's question
because it goes much more thoroughly into the specific issues of
tables, but I agree that the stone page does mention tables.

I think there is one problem with the suggested solution, which was

<div style="text-align: center;">
<div style="text-align: left; margin: 1em auto; width: 50%;">
</div>
</div>

When centering a table, if you do

<div style="text-align: center;">
<table style="text-align: left; margin: 1em auto; width: 50%;">
</table>
</div>

then doesn't that cause the <th> elements also to be left aligned,
by inheritance?

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #8
Stan Brown wrote:
I think Nick Theodorakis' page is much better for the OP's question
because it goes much more thoroughly into the specific issues of
tables, but I agree that the stone page does mention tables.
Other then the <th> issue you mention below, there aren't any table specific
issues (at least with CSS centring methods). They are just block level
elements.
When centering a table, if you do

<div style="text-align: center;">
<table style="text-align: left; margin: 1em auto; width: 50%;">
</table>
</div>

then doesn't that cause the <th> elements also to be left aligned,
by inheritance?


Nothing preventing you from having:

..tableWrapper { text-align: center; }
table { text-align: left; margin: auto 1em; }
th { text-align: center; }
--
David Dorward http://david.us-lot.org/
Jul 20 '05 #9
In article <bf*******************@news.demon.co.uk> in
comp.infosystems.www.authoring.html, David Dorward
<do*****@yahoo.com> wrote:
Nothing preventing you from having:

.tableWrapper { text-align: center; }
table { text-align: left; margin: auto 1em; }
th { text-align: center; }


Agreed -- my point was that the page doesn't even raise the issue
and someone who posts "how do I center a table?" isn't likely to
guess that it's needed.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #10

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

Similar topics

6
by: adam | last post by:
The folowing code produces an error althought i cant understand why it does this can any one help? THANKS ERROR = Notice: Undefined variable: tab in C:\Inetpub\wwwroot\carpound\table\table1.php...
2
by: Jim | last post by:
Im getting way too many rows retured..what its trying to do is insert a 0 for revenue for months 7 - 12 (aka July through December) for each of these cost centers for each payor type..Im getting a...
0
by: PayPal | last post by:
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control"> <TITLE></TITLE> </HEAD> <BODY> <STYLE type=text/css> ..dummy {} BODY, TD {font-family:...
3
by: francisco lopez | last post by:
I hope not sent I twice. ok here is my problem, the javascript form validation works perfect during I put a emaildirection in the <form action:""> comand, like this: <form...
7
by: ALI-R | last post by:
Hi All, I have two user controls (header and footer) ,,which I've placed in an HTML Table in a page.I set the **align="center"** in the table and the table still is on the left side of the page...
2
by: yangtono | last post by:
Hi, I am creating a table to list some data. The table is using a sorting and highlight function that I found from the net. I can't attach image here, basically html will wrap the heading,...
14
by: gaijinco | last post by:
I was a hobbist web coder for years but I had to sidestep for a while. Now I'm trying to return to it and I'm trying to clarify how am I supposed to do somethings with CSS v.s. HTML and I'm...
13
by: Stevo | last post by:
I've found that for IE6+, if you add the property text-align:center to a DIV, then *anything* inside it gets centered. That can be a table, an object/embed, another DIV, an image, or some text. ...
8
by: Bob Altman | last post by:
Hi all, This has got to be a dumb question, but... What is the CSS property that I would use to center a table on the web page? If I set the table's Align property in the VS 2008 property...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.