Connecting Tech Pros Worldwide Forums | Help | Site Map

Firefox, Div tags, Tables and Centering problems

Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#1: Jan 31 '07
Hi there!

I don't know why I seem to be the only one with this problem...In Firefox when I'm displaying a table within a <div> and use the align="center" it does not center the table. I'm wondering if there is a way around this...

Eg
Expand|Select|Wrap|Line Numbers
  1. <div id="mainContent">
  2.      <table align="center">
  3.           ...
  4.      </table>
  5. </div>
  6.  
Thanks for your help!

-Frinny

Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#2: Jan 31 '07

re: Firefox, Div tags, Tables and Centering problems


Quote:

Originally Posted by Frinavale

Hi there!

I don't know why I seem to be the only one with this problem...In Firefox when I'm displaying a table within a <div> and use the align="center" it does not center the table. I'm wondering if there is a way around this...

Eg

Expand|Select|Wrap|Line Numbers
  1. <div id="mainContent">
  2.      <table align="center">
  3.           ...
  4.      </table>
  5. </div>
  6.  
Thanks for your help!

-Frinny

Hey Frinny glad to see you made your way to the HTML forum!
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>STUFF</title>
  5. <style type="text/css">
  6. .clsTest
  7. {
  8. /* Centers in FF */
  9. text-align: -moz-center;
  10. /* Centers in IE */
  11. text-align: center;
  12. }
  13.  
  14. </style>
  15. </head>
  16. <body>
  17. <div class="clsTest">
  18.      <table style="border: 2px solid black">
  19.         <tr>
  20.         <td>Some Crap</td>
  21.     </tr>
  22.      </table>
  23. </div>
  24. </body>
  25. <html>
  26.  
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#3: Feb 1 '07

re: Firefox, Div tags, Tables and Centering problems


align="center" is deprecated. Don't use it.

He wants to center the table, not the text. With typos fixed:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title></title>
  5. <style type="text/css">
  6.  
  7. table
  8. {
  9. margin:0 auto;
  10. }
  11.  
  12. </style>
  13. </head>
  14. <body>
  15. <div class="clsTest">
  16.      <table style="border: 2px solid black">
  17.         <tr>
  18.         <td>Some Crap</td>
  19.     </tr>
  20.      </table>
  21. </div>
  22. </body>
  23. </html>
  24.  
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#4: Feb 1 '07

re: Firefox, Div tags, Tables and Centering problems


Quote:

Originally Posted by drhowarddrfine

With typos fixed:

</html> :)
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Feb 1 '07

re: Firefox, Div tags, Tables and Centering problems


Quote:

Originally Posted by AricC

Expand|Select|Wrap|Line Numbers
  1. ...
  2. <title>STUFF</title>
  3. ...        <td>Some Crap</td>
  4. ...

Aric, could you not think of better test words?!
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#6: Feb 1 '07

re: Firefox, Div tags, Tables and Centering problems


Quote:

Originally Posted by drhowarddrfine

...

Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2.  
  3. table
  4. {
  5. margin:0 auto;
  6. }
  7.  
  8. </style>
  9.  

Thanks so much its working perfectly now :)

-Frinny
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#7: Feb 1 '07

re: Firefox, Div tags, Tables and Centering problems


That's just the kind of guy I am. Perfect.
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#8: Feb 1 '07

re: Firefox, Div tags, Tables and Centering problems


Quote:

Originally Posted by acoder

Aric, could you not think of better test words?!

I changed it, whooops LMAO sorry guys yesterday was a completely heinous work day. The kind where you go straight to the pub after work. Which I did, today should be better :) Thanks for the fix Doc I wouldn't want to look like a total arse!

Aric
Reply