473,796 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ 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%;marg in-left:auto;margi n-right:auto;}
</style>
firefox work fine but MSIE set the margin to zero
Thank in advance
May 31 '07 #1
13 2782
On May 31, 10:56 am, "Pablo" <p...@nospam.co mwrote:
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%;marg in-left:auto;margi n-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"h as 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************ ********@reader 1.news.saunalah ti.fi>,
"Jukka K. Korpela" <jk******@cs.tu t.fiwrote:
Scripsit Pablo:
I'ld like to center a table crossbrowser therefore I wrote:
<sryle>
table {width:80%;marg in-left:auto;margi n-right:auto;}
</style>
[snip]
Besides, <table align="center"h as 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"h as 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************ ********@reader 1.news.saunalah ti.fi>,
"Jukka K. Korpela" <jk******@cs.tu t.fiwrote:
Besides, <table align="center"h as 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 .uni-hannover.de>,
Andreas Prilop <An************ ***@trashmail.n etwrote:
On Thu, 31 May 2007, David Stone wrote:
Besides, <table align="center"h as 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"h as 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"h as worked ever since Netscape 2 and IE
2. Why do people take great pains in avoiding such simple
presentation al 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"y ou 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 "deprecatio n").

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.tu t.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%">Lef t content</td>
<td width="80%">Cen ter content</td>
<td width="10%">Rig ht 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

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

Similar topics

0
1544
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
2137
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 Steel
0
1618
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 the screen and is right on FireFox elseif I write menubar {position: absolute;top:100px;} the menu bar is right with NSIE and not with FF How can I do to have a crossbrowser result of my menu var?
53
4141
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 javascript object and that's all. No need to know CSS hacks, no need to clutter your html with tables. http://www.bravelayout.scarabeo.biz/Quickstart
2
16367
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 arrow when user click on the header to sort. The code is as below: <TABLE width="100%">
14
2435
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 to dodge the issue) I also have a doubt. html-atributes width and height are preferred over...
13
3324
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, object/embeds or tables remain default unaligned and generally appear on the left. Considering...
1
1764
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
7884
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 need to use a CSS style to do the same thing. But I've dug through all of the categories in the...
0
9685
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10242
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.