467,907 Members | 1,426 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

To center a table crossbrowser

Hi at all
I'ld like to center a table crossbrowser therefore I wrote:
<sryle>
table {width:80%;margin-left:auto;margin-right:auto;}
</style>
firefox work fine but MSIE set the margin to zero
Thank in advance
May 31 '07 #1
  • viewed: 2491
Share:
13 Replies
On May 31, 10:56 am, "Pablo" <p...@nospam.comwrote:
I'ld like to center a table crossbrowser
firefox work fine but MSIE set the margin to zero
http://dorward.me.uk/www/centre/#ie

--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/

May 31 '07 #2
Scripsit Pablo:
I'ld like to center a table crossbrowser therefore I wrote:
<sryle>
table {width:80%;margin-left:auto;margin-right:auto;}
</style>
Are you sure? I bet that's not the real markup. Hint: post the URL if in
doubt, and you should be in doubt.
firefox work fine but MSIE set the margin to zero
You used incorrect HTML (no doctype or malformed doctype), throwing MSIE
deep into Quirks Mode. This _also_ means that if you simply add a correct
doctype, other errors may well make your page crumble down; see
http://www.cs.tut.fi/~jkorpela/quirks-mode.html

But in this case, you can simply set margin-left and margin-right to 10%,
avoiding the issue.

Besides, <table align="center"has worked ever since Netscape 2 and IE 2.
Why do people take great pains in avoiding such simple presentational
markup, on pages that otherwise suffer from divitis, pixelitis,
hidelinkitis, and all other sorts of horrendeous diseases?

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

May 31 '07 #3
In article <Qt********************@reader1.news.saunalahti.fi >,
"Jukka K. Korpela" <jk******@cs.tut.fiwrote:
Scripsit Pablo:
I'ld like to center a table crossbrowser therefore I wrote:
<sryle>
table {width:80%;margin-left:auto;margin-right:auto;}
</style>
[snip]
Besides, <table align="center"has worked ever since Netscape 2 and IE 2.
Why do people take great pains in avoiding such simple presentational
markup, on pages that otherwise suffer from divitis, pixelitis,
hidelinkitis, and all other sorts of horrendeous diseases?
I'm curious as to why you would be recommending a deprecated attribute?

I don't remember if the OP had some specific doctype or html/css version
in mind, but given the newsgroup I'm a little surprised. What am I
missing?
May 31 '07 #4
On Thu, 31 May 2007, David Stone wrote:
>Besides, <table align="center"has worked ever since Netscape 2 and IE 2.
Why do people take great pains in avoiding such simple presentational
markup, on pages that otherwise suffer from divitis, pixelitis,
hidelinkitis, and all other sorts of horrendeous diseases?

I'm curious as to why you would be recommending a deprecated attribute?
A deprecated attribute from HTML 4 Transitional would be the
smallest crime on such ill-designed pages.

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sear...Alan.J.Flavell
May 31 '07 #5
In article <Qt********************@reader1.news.saunalahti.fi >,
"Jukka K. Korpela" <jk******@cs.tut.fiwrote:
Besides, <table align="center"has worked ever since Netscape 2 and IE 2.
Why do people take great pains in avoiding such simple presentational
markup, on pages that otherwise suffer from divitis, pixelitis,
hidelinkitis, and all other sorts of horrendeous diseases?
For the same reason people stick to rules blindly everywhere
else. Because they do not understand the context of the creation
of rules or their true purpose.

--
dorayme
May 31 '07 #6
In article
<Pi******************************@s5b004.rrzn.un i-hannover.de>,
Andreas Prilop <An***************@trashmail.netwrote:
On Thu, 31 May 2007, David Stone wrote:
Besides, <table align="center"has worked ever since Netscape 2 and IE 2.
Why do people take great pains in avoiding such simple presentational
markup, on pages that otherwise suffer from divitis, pixelitis,
hidelinkitis, and all other sorts of horrendeous diseases?
I'm curious as to why you would be recommending a deprecated attribute?

A deprecated attribute from HTML 4 Transitional would be the
smallest crime on such ill-designed pages.
True. But the real answer to the query is that the overall crime
would thereby be lessened. In the way that a badly dressed guest
at a royal function would cause eyebrows to be even more raised
than usual if she sounded like Eliza Doolittle training to talk
better.

--
dorayme
May 31 '07 #7
Jukka K. Korpela wrote:
<table align="center"has worked ever since Netscape 2 and IE
2. Why do people take great pains in avoiding such simple presentational
markup, on pages that otherwise suffer from divitis, pixelitis,
hidelinkitis, and all other sorts of horrendeous diseases?
Nobody uses NS2, NS3, IE3 and/or IE4. According to an unanimity of world
web stats sources, less than 1% of web people now use MSIE 5.x and/or NS
4.x or lower. So, well above 95% of all graphical CSS-capable web
browsers will render accordingly margin-left: auto; margin-right: auto;.

And if a browser can not render margin-left: auto; margin-right: auto;,
then no big deal; the table won't be centered. The whole content should
nevertheless still be accessible (as expected) and links/navigation
should still be functional (as expected).

Gérard
--
Using Web Standards in your Web Pages (Updated Apr. 2007)
http://developer.mozilla.org/en/docs...your_Web_Pages
Jun 2 '07 #8
Scripsit Gérard Talbot:
Jukka K. Korpela wrote:
><table align="center"has worked ever since Netscape 2 and IE
2. Why do people take great pains in avoiding such simple
presentational markup, on pages that otherwise suffer from divitis,
pixelitis, hidelinkitis, and all other sorts of horrendeous diseases?

Nobody uses NS2, NS3, IE3 and/or IE4.
First of all, you seem to have missed the "ever since" part.

Second, at least of the regulars of sci.lang has declared that he uses
Netscape 3 and has no intentions of changing it because it does everything
he needs. There's little reason why someone could not use IE 3, naturally
with style sheets turned off (the simplicity of doing that is the best part
in its CSS support). Of course you will see unstyled content, so you need to
be interested in content mainly. But why bother turning off CSS support in
order to view an otherwise hopelessly messy page when you can use a good old
browser with such a setting built in? :-)
According to an unanimity of
world web stats sources, less than 1% of web people now use MSIE 5.x
and/or NS
As usual, we need to take into account the fact that 94.1 % of all web
statistics have just been made up and the rest 6.9 were calculated
incorrectly. But assuming that a little less than 1 % were the correct
figure (we cannot possibly know), how many _millions_ of people would that
make? But that's not important right now.
So, well above 95% of all graphical CSS-capable web
browsers will render accordingly margin-left: auto; margin-right:
auto;.
Well, yes, assuming that you percentages are correct and browsers have CSS
support enabled and no CSS bug bites you.

And naturally assuming that the browser runs in Standards Mode. Even IE 7
refuses to honor the CSS rule in Quirks Mode.

The point is that by using <table align="center"you get as close to 100 %
as possible, as regards to browsers that present tables visually in the
first place.

Is there _any_ tangible or even imaginable drawback from using the
align="center" attribute? Assuming we don't count any verbal objections that
don't give any arguments except references to other parties' verbal
objections (like "deprecation").

Thus, I repeat my question: Why do people take great pains in avoiding such
simple presentational markup, on pages that otherwise suffer from divitis,
pixelitis, hidelinkitis, and all other sorts of horrendeous diseases?

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

Jun 2 '07 #9
VK
On Jun 2, 12:37 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
Thus, I repeat my question: Why do people take great pains in avoiding such
simple presentational markup, on pages that otherwise suffer from divitis,
pixelitis, hidelinkitis, and all other sorts of horrendeous diseases?
I dare to say for the same reason why instead of for instance:

<table width="100%">
<tr>
<td width="10%">Left content</td>
<td width="80%">Center content</td>
<td width="10%">Right content</td>
<tr>
</table>

they are spending hours and days for some twisted div agglomerations
followed by huge stylesheets where 90% are different UA-specific
tricks and workarounds. Truly the amount of online resources about div-
based table layouts now allows to publish a 1000-page scientific
volume :-) Yet every single "universal solution" I tested so far
reminds me a domino tower: it falls apart on the slightest push - that
besides the fact that the layout functionality is still below the one
provided by a few lines above.

So the reason is that during the "cold war" of 2001-2007 Web
technologies were shifted somehow from purely technical aspect to some
"spiritual" one. So instead of a normal approach "what does work in
the most stable way in the biggest amount of environments?", the main
preoccupation became "what is the most correct by W3C way to do it?".

As you contributed a lot in similar discussions, you current surprise
seems to me a bit artificial. WIth a spiritual approach to the Web
development the conventional logic doesn't fully apply as you know.
The main principle becomes "an attempt does count for my good doings -
even if failed" thus at attempt to be good is already good. This is
why ciwas and ciwah are seeing these strange combos of poorly made
pages with insertions of sophisticated approaches here and there:
oftenly out of any context and sense. Just like someone say trying to
spell "Pater Noster" with half of Latin words twisted and
mispronounced: in expectation that the Lord lessens the heart and not
the mouth.
:-)

Jun 2 '07 #10
In article
<11**********************@m36g2000hse.googlegroups .com>,
VK <sc**********@yahoo.comwrote:
As you contributed a lot in similar discussions, you current surprise
seems to me a bit artificial.
What sort of sentence is this? Don't you care at all how you
write?

--
dorayme
Jun 2 '07 #11
VK
VK <schools_r...@yahoo.comwrote:
As you contributed a lot in similar discussions, you current surprise
seems to me a bit artificial.

What sort of sentence is this? Don't you care at all how you
write?
Sapienti sat, but OK:

"Given your own position on relevant issues demonstrated in many
previous discussions: given that you current surprise seems to me a
bit artificial."

Other words: if one was getting furious on each deprecated or
semantically incorrect HTML/CSS usage, then why is this person being
surprised to see OP not daring to use a deprecated attribute, whatever
benefits would be?
Jun 2 '07 #12
In article
<11**********************@o5g2000hsb.googlegroups. com>,
VK <sc**********@yahoo.comwrote:
VK <schools_r...@yahoo.comwrote:
As you contributed a lot in similar discussions, you current surprise
seems to me a bit artificial.
What sort of sentence is this? Don't you care at all how you
write?

Sapienti sat, but OK:

"Given your own position on relevant issues demonstrated in many
previous discussions: given that you current surprise seems to me a
bit artificial."

Other words: if one was getting furious on each deprecated or
semantically incorrect HTML/CSS usage, then why is this person being
surprised to see OP not daring to use a deprecated attribute, whatever
benefits would be?
OK, sorry, I was in a grumpy mood earlier.

I think the answer to your puzzlement lies in understanding that
some things are even more infuriating than others. It is
infuriating to see someone blindly trying to follow some rules at
the cost of great impracticality given their skills. On the other
hand, it is also infuriating to see someone making little effort
to follow good practice. The way these things play out in
practice and the reactions to them is not a neat simple business
with simple rules. We are in an inferno here and JK is just
negotiating the fires.

--
dorayme
Jun 2 '07 #13
VK wrote:
On Jun 2, 12:37 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
>Thus, I repeat my question: Why do people take great pains in avoiding such
simple presentational markup, on pages that otherwise suffer from divitis,
pixelitis, hidelinkitis, and all other sorts of horrendeous diseases?

I dare to say for the same reason why instead of for instance:

<table width="100%">
<tr>
<td width="10%">Left content</td>
<td width="80%">Center content</td>
<td width="10%">Right content</td>
<tr>
</table>

they are spending hours and days for some twisted div agglomerations
followed by huge stylesheets where 90% are different UA-specific
tricks and workarounds. Truly the amount of online resources about div-
based table layouts now allows to publish a 1000-page scientific
volume :-) Yet every single "universal solution" I tested so far
reminds me a domino tower: it falls apart on the slightest push - that
besides the fact that the layout functionality is still below the one
provided by a few lines above.
If you think it takes hours and huge stylesheets and twisted div then
you are probably being a code monkey and over-complicating your markup.
Yes, it is pretty simple to layout 3 vertical columns that way with a
table. But that initial perceived simplicity can really bite you in the
backside if you decide to change your layout from three columns side by
side to one along the top followed by two side by side, or all vertical
top middle and bottom, AND the site is 100+ pages. Your "simple' table
layout would require a complete rewrite of all said pages whereas if
done properly via CSS that change can be make by editing one stylesheet.
In addition restricting your markup to structure and content and using
CSS for the presentation your can offer alternated styles for the same
pages. An example would be a simplified styling with large high-contrast
text and linear layout for the visually impaired...making your site
more accommodating.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jun 2 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by PayPal | last post: by
3 posts views Thread by Steel | last post: by
reply views Thread by Pablito | last post: by
2 posts views Thread by yangtono | last post: by
14 posts views Thread by gaijinco | last post: by
1 post views Thread by par7133 | last post: by
8 posts views Thread by Bob Altman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.