473,480 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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
13 2730
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1520
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
2100
by: Steel | last post by:
Hi at all, I'ld want to know if position:absolute is crossbrowser. Infact I cannot position absolutely an element in the some place with fox-pro and MSIE6 There is always a little difference...
0
1588
by: Pablito | last post by:
Hi at all, I have a little problem about position:absolute. I want to position absolutely a menu bar. if I write: menubar {position: absolute;top:5.2em;} with MSIE the menu bar is too height on...
53
4058
by: brave1979 | last post by:
Please check out my javascript library that allows you to create any layout for your web page, nested as deep as you like, adjusting to width and height of a browser window. You just describe it in...
2
16339
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
2381
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
3265
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. ...
1
1740
by: par7133 | last post by:
Hi, Yea, XMLHttpRequest give out a crossbrowser problem managing the status change of the connection. Here the solution: var xmlhttp; xmlhttp=null;
8
7843
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
7092
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...
1
6744
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5348
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,...
1
4790
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
4488
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...
0
3000
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...
0
2989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
188
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...

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.