View Full Version : <div align="center"> vs <table align="center"&...
morrisdan1
12-30-2000, 05:55 PM
When centering tables. I tend to write the codes as shown below:
<div align="center">
[nbsp][nbsp]<table border="1">
[nbsp][nbsp][nbsp][nbsp]<tr><td>whatever</td></tr>
[nbsp][nbsp]</table>
</div>
For the sake of clarity, wouldn I be better off to write it as shown below ?:
<table border="1" align="center">
[nbsp][nbsp]<tr><td>whatever</td></tr>
</table>
The only thing is that would it make much of a difference[nbsp][nbsp]browser-wise ? Do the current or more well-known browsers recognize the <table border="1" align="center"> command ? Please advise. Thanks !
Hunkorama417
12-30-2000, 06:45 PM
Actually it's opposite of what you thought. The first example is 4x compatible, while the second example is 3x compatible. I always use the second example because it's easier to type and it's 3x compatible.
------------------
Andrew
www.digi-FX.net (http://www.digi-FX.net)
Keiichi
12-31-2000, 02:42 AM
it's best to stick with the second one. like the SPAN tag, DIV tags are often used with CSS for additional adjustments and can really make your page look a little different
In HTML 4.0 the align parameter is deprecated. For maximum compatibility across browser versions use:
<div align="center"><font color=#FF0000><center></font>
[nbsp][nbsp]<table border="1">
[nbsp][nbsp][nbsp][nbsp]<tr><td>whatever</td></tr>
[nbsp][nbsp]</table>
<font color=#FF0000></center></font></div>
Rich
Jenny
01-01-2001, 04:31 AM
Maybe I am not following you, Rich, but I disagree with you, I'm afraid! My understanding is that the <center> tag is deprecated and that the "align" attribute is what should be used in its place (until it's safe to do all positioning with CSS of course).
Cheers :)
Jenny
Yes, Jenny, you are partially correct. :)
Actually, the center tag, the table align tag, AND the div align tag are ALL deprecated in the latest HTML specification in preference to style sheets.
Your original questions asked about how to achieve compatibility with most browsers, which the above code will do in over 99% of the cases.
However, to be technically complete, I should have advised the following:
1. Use CSS to center align the table
-AND-
2. Write table code as follows:
<div align="center"><center>
[nbsp][nbsp]<table align="center" border="1">
[nbsp][nbsp][nbsp][nbsp]<tr><td>whatever</td></tr>
[nbsp][nbsp]</table>
</center></div>
Rich
-- "Accurate code does not always produce useable code."
[This message has been edited by Rich (edited 01-01-01@06:05 am)]
Keiichi
01-01-2001, 03:38 PM
so much stuff just to center a table :þ
Jenny
01-06-2001, 07:24 PM
Oops, yes, sorry Rich, you are of course completely right :) !
I was relying too heavily on my copy of HTML4 Unleashed and failed to check out more recent specs...
Cheers,
Jenny
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.