By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,723 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,723 IT Pros & Developers. It's quick & easy.

Firefox, Div tags, Tables and Centering problems

Frinavale
Expert Mod 5K+
P: 9,731
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
Jan 31 '07 #1
Share this Question
Share on Google+
7 Replies


Expert 100+
P: 1,892
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.  
Jan 31 '07 #2

drhowarddrfine
Expert 5K+
P: 7,435
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.  
Feb 1 '07 #3

Expert 100+
P: 1,892
With typos fixed:
</html> :)
Feb 1 '07 #4

acoder
Expert Mod 15k+
P: 16,027
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?!
Feb 1 '07 #5

Frinavale
Expert Mod 5K+
P: 9,731
...
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
Feb 1 '07 #6

drhowarddrfine
Expert 5K+
P: 7,435
That's just the kind of guy I am. Perfect.
Feb 1 '07 #7

Expert 100+
P: 1,892
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
Feb 1 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.