473,545 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10686
Bjoern Wolfgardt <14************ *************@p osting.google.c om> wrote in
comp.infosystem s.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************ *************@p osting.google.c om> in
comp.infosystem s.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;MARGI N-RIGHT:auto"
border="1">

cu
Bjoern Wolfgardt

Stan Brown <th************ @fastmail.fm> wrote in message news:<MP******* *************** **@news.odyssey .net>...
In article <14************ *************@p osting.google.c om> in
comp.infosystem s.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.PYKUYF uaPT@geoffball> in
comp.infosystem s.www.authoring.html, Geoff Ball <ge********@sha w.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;MARGI N-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.de mon.co.uk> in
comp.infosystem s.www.authoring.html, David Dorward
<do*****@yahoo. com> wrote:
Stan Brown wrote:
In article <1234666.PYKUYF uaPT@geoffball> in
comp.infosystem s.www.authoring.html, Geoff Ball <ge********@sha w.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.de mon.co.uk> in
comp.infosystem s.www.authoring.html, David Dorward
<do*****@yahoo. com> wrote:
Nothing preventing you from having:

.tableWrappe r { 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
1623
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 on line 32 <?php $link = mysql_connect("localhost","root","admin") or die(mysql_error()); mysql_select_db("car") or die (mysql_error());
2
7797
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 lot of repeats and the concatenation field date always comes back as January 2003 instead of the month and date its supposed to --Fiscal...
0
1526
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: verdana,arial,helvetica,sans-serif;font-size: 12px;color: #000000;}
3
2156
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 action="mailto:butacasalada@gmx.net" method="post" name="formulario" id="formulario" onSubmit="return chkFormular()">
7
4161
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 .How can I get the whole page(Table and its user controls) aligned in the center of my page? Thanks for your time in advance. Ali
2
16347
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, therefore I notice the second line of the header is left align instead of centering. I believe it's because of the sort.htc script that will output an...
14
2392
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 specially having difficulties with center alignment of elements like images and tables. How is the "right" way to do it? (books that I have checked seemed...
13
3270
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. Firefox and Safari on the other hand don't treat text-align in that way. In my tests on those browsers, they only centers images and text. Any DIVs,...
8
7858
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 window it inserts align="center" into the <tabletag, and I get a validation warning that attribute 'align' is considered outdated. Ok, so I probably...
0
7479
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7926
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4962
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.