473,840 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to center a table?

347 Contributor
I have a web page that I converted from a psd file to html with Photoshop and imported into Dreamweaver. The problem I'm having is that some viewers comment on the fact that the page is left justified. I inserted a div tag into the html with a wrap around selection and tried to modify the css rules so that this would align properly, and the page is still aligning left justified. Here is the code that I have for my css:

Expand|Select|Wrap|Line Numbers
  1. #site_layout {
  2.     font-family: "Franklin Gothic Demi Cond";
  3.     background-color: #FFF;
  4.     height: auto;
  5.     width: auto;
  6.     margin-left: auto;
  7.     margin-right: auto;
  8. }
and here is the html for the web site:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>MSB secondary page template</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <link href="site_layout.css" rel="stylesheet" type="text/css">
  6. </head>
  7. <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  8. <!-- Save for Web Slices (MSB secondary page template.psd) -->
  9. <div id="container">
  10.   <div id="site_layout">
  11.     <div class="css" id="site_layout.css">
  12.       <table width="1260" height="811" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
  13.         <tr>
  14.           <td colspan="26" align="center" bgcolor="#FFFFFF">
  15.             <img src="images/MSB-secondary-page-template_01.gif" width="1259" height="24" alt=""></td>
  16.           <td>
  17.             <img src="images/spacer.gif" width="1" height="24" alt=""></td>
  18.           </tr>
  19.         <tr>
  20.           <td colspan="20" rowspan="2" align="center" bgcolor="#FFFFFF">
  21.             <img src="images/MSB-secondary-page-template_02.gif" width="1036" height="48" alt=""></td>
  22.           <td colspan="2" align="center" bgcolor="#FFFFFF">
  23.             <img src="images/MSB-secondary-page-template_03.jpg" width="60" height="22" alt=""></td>
  24.           <td colspan="4" rowspan="5" align="center" bgcolor="#FFFFFF">
  25.             <img src="images/MSB-secondary-page-template_04.gif" width="163" height="65" alt=""></td>
  26.           <td>
  27.             <img src="images/spacer.gif" width="1" height="22" alt=""></td>
  28.           </tr>
  29.         <tr>
  30.           <td colspan="2" rowspan="4" align="center" bgcolor="#FFFFFF">
  31.             <img src="images/MSB-secondary-page-template_05.gif" width="60" height="43" alt=""></td>
  32.           <td>
  33.             <img src="images/spacer.gif" width="1" height="26" alt=""></td>
  34.           </tr>
  35.         <tr>
  36.           <td colspan="19" align="center" bgcolor="#FFFFFF">
  37.             <img src="images/MSB-secondary-page-template_06.gif" width="873" height="8" alt=""></td>
  38.           <td rowspan="5" align="center" bgcolor="#FFFFFF">
  39.             <img src="images/MSB-secondary-page-template_07.jpg" width="163" height="58" alt=""></td>
  40.           <td>
  41.             <img src="images/spacer.gif" width="1" height="8" alt=""></td>
  42.           </tr>
  43.         <tr>
  44.           <td colspan="3" rowspan="5" align="center" bgcolor="#FFFFFF">
  45.             <img src="images/MSB-secondary-page-template_08.gif" width="166" height="51" alt=""></td>
  46.           <td rowspan="5" align="center" bgcolor="#FFFFFF">
  47.             <img src="images/MSB-secondary-page-template_09.jpg" width="120" height="51" alt=""></td>
  48.           <td rowspan="5" align="center" bgcolor="#FFFFFF">
  49.             <img src="images/MSB-secondary-page-template_10.gif" width="16" height="51" alt=""></td>
  50.           <td rowspan="5" align="center" bgcolor="#FFFFFF">
  51.             <img src="images/MSB-secondary-page-template_11.jpg" width="120" height="51" alt=""></td>
  52.           <td colspan="13" align="center" bgcolor="#FFFFFF">
  53.             <img src="images/MSB-secondary-page-template_12.gif" width="451" height="1" alt=""></td>
  54.           <td>
  55.             <img src="images/spacer.gif" width="1" height="1" alt=""></td>
  56.           </tr>
  57.         <tr>
  58.           <td rowspan="4" align="center" bgcolor="#FFFFFF">
  59.             <img src="images/MSB-secondary-page-template_13.gif" width="19" height="50" alt=""></td>
  60.           <td colspan="2" rowspan="4" align="center" bgcolor="#FFFFFF">
  61.             <img src="images/MSB-secondary-page-template_14.jpg" width="119" height="50" alt=""></td>
  62.           <td colspan="2" rowspan="4" align="center" bgcolor="#FFFFFF">
  63.             <img src="images/MSB-secondary-page-template_15.gif" width="22" height="50" alt=""></td>
  64.           <td colspan="4" rowspan="4" align="center" bgcolor="#FFFFFF">
  65.             <img src="images/MSB-secondary-page-template_16.jpg" width="118" height="50" alt=""></td>
  66.           <td rowspan="4" align="center" bgcolor="#FFFFFF">
  67.             <img src="images/MSB-secondary-page-template_17.gif" width="19" height="50" alt=""></td>
  68.           <td colspan="2" rowspan="4" align="center" bgcolor="#FFFFFF">
  69.             <img src="images/MSB-secondary-page-template_18.jpg" width="118" height="50" alt=""></td>
  70.           <td rowspan="4" align="center" bgcolor="#FFFFFF">
  71.             <img src="images/MSB-secondary-page-template_19.gif" width="36" height="50" alt=""></td>
  72.           <td>
  73.             <img src="images/spacer.gif" width="1" height="8" alt=""></td>
  74.           </tr>
  75.         <tr>
  76.           <td rowspan="3" align="center" bgcolor="#FFFFFF">
  77.             <img src="images/MSB-secondary-page-template_20.gif" width="8" height="42" alt=""></td>
  78.           <td colspan="2" align="center" bgcolor="#FFFFFF">
  79.             <img src="images/MSB-secondary-page-template_21.jpg" width="58" height="24" alt=""></td>
  80.           <td colspan="3" rowspan="3" align="center" bgcolor="#FFFFFF">
  81.             <img src="images/MSB-secondary-page-template_22.gif" width="157" height="42" alt=""></td>
  82.           <td>
  83.             <img src="images/spacer.gif" width="1" height="24" alt=""></td>
  84.           </tr>
  85.         <tr>
  86.           <td colspan="2" rowspan="2" align="center" bgcolor="#FFFFFF">
  87.             <img src="images/MSB-secondary-page-template_23.gif" width="58" height="18" alt=""></td>
  88.           <td>
  89.             <img src="images/spacer.gif" width="1" height="17" alt=""></td>
  90.           </tr>
  91.         <tr>
  92.           <td align="center" bgcolor="#FFFFFF">
  93.             <img src="images/MSB-secondary-page-template_24.gif" width="163" height="1" alt=""></td>
  94.           <td>
  95.             <img src="images/spacer.gif" width="1" height="1" alt=""></td>
  96.           </tr>
  97.         <tr>
  98.           <td rowspan="4" align="center" bgcolor="#FFFFFF">
  99.             <img src="images/MSB-secondary-page-template_25.gif" width="148" height="665" alt=""></td>
  100.           <td colspan="15" align="center" bgcolor="#FFFFFF">
  101.             <img src="images/MSB-secondary-page-template_26.jpg" width="571" height="221" alt=""></td>
  102.           <td colspan="8" align="center" bgcolor="#FFFFFF">
  103.             <img src="images/MSB-secondary-page-template_27.jpg" width="405" height="221" alt=""></td>
  104.           <td colspan="2" rowspan="4" align="center" bgcolor="#FFFFFF">
  105.             <img src="images/MSB-secondary-page-template_28.gif" width="135" height="665" alt=""></td>
  106.           <td>
  107.             <img src="images/spacer.gif" width="1" height="221" alt=""></td>
  108.           </tr>
  109.         <tr>
  110.           <td rowspan="3" align="center" bgcolor="#FFFFFF">
  111.             <img src="images/MSB-secondary-page-template_29.gif" width="1" height="444" alt=""></td>
  112.           <td colspan="22" align="center" bgcolor="#FFFFFF">
  113.             <img src="images/MSB-secondary-page-template_30.gif" width="975" height="402" alt=""></td>
  114.           <td>
  115.             <img src="images/spacer.gif" width="1" height="402" alt=""></td>
  116.           </tr>
  117.         <tr>
  118.           <td colspan="6" rowspan="2" align="center" bgcolor="#FFFFFF">
  119.             <img src="images/MSB-secondary-page-template_31.gif" width="388" height="42" alt=""></td>
  120.           <td colspan="2" align="center" bgcolor="#FFFFFF">
  121.             <img src="images/MSB-secondary-page-template_32.jpg" width="44" height="21" alt=""></td>
  122.           <td colspan="2" rowspan="2" align="center" bgcolor="#FFFFFF">
  123.             <img src="images/MSB-secondary-page-template_33.gif" width="12" height="42" alt=""></td>
  124.           <td align="center" bgcolor="#FFFFFF">
  125.             <img src="images/MSB-secondary-page-template_34.jpg" width="77" height="21" alt=""></td>
  126.           <td rowspan="2" align="center" bgcolor="#FFFFFF">
  127.             <img src="images/MSB-secondary-page-template_35.gif" width="10" height="42" alt=""></td>
  128.           <td colspan="3" align="center" bgcolor="#FFFFFF">
  129.             <img src="images/MSB-secondary-page-template_36.jpg" width="53" height="21" alt=""></td>
  130.           <td colspan="7" rowspan="2" align="center" bgcolor="#FFFFFF">
  131.             <img src="images/MSB-secondary-page-template_37.gif" width="391" height="42" alt=""></td>
  132.           <td>
  133.             <img src="images/spacer.gif" width="1" height="21" alt=""></td>
  134.           </tr>
  135.         <tr>
  136.           <td colspan="2" align="center" bgcolor="#FFFFFF">
  137.             <img src="images/MSB-secondary-page-template_38.gif" width="44" height="21" alt=""></td>
  138.           <td align="center" bgcolor="#FFFFFF">
  139.             <img src="images/MSB-secondary-page-template_39.gif" width="77" height="21" alt=""></td>
  140.           <td colspan="3" align="center" bgcolor="#FFFFFF">
  141.             <img src="images/MSB-secondary-page-template_40.gif" width="53" height="21" alt=""></td>
  142.           <td>
  143.             <img src="images/spacer.gif" width="1" height="21" alt=""></td>
  144.           </tr>
  145.         <tr>
  146.           <td colspan="25" align="center" bgcolor="#FFFFFF">
  147.             <img src="images/MSB-secondary-page-template_41.jpg" width="1250" height="14" alt=""></td>
  148.           <td align="center" bgcolor="#FFFFFF">
  149.             <img src="images/MSB-secondary-page-template_42.gif" width="9" height="14" alt=""></td>
  150.           <td>
  151.             <img src="images/spacer.gif" width="1" height="14" alt=""></td>
  152.           </tr>
  153.         <tr>
  154.           <td>
  155.             <img src="images/spacer.gif" width="148" height="1" alt=""></td>
  156.           <td>
  157.             <img src="images/spacer.gif" width="1" height="1" alt=""></td>
  158.           <td>
  159.             <img src="images/spacer.gif" width="17" height="1" alt=""></td>
  160.           <td>
  161.             <img src="images/spacer.gif" width="120" height="1" alt=""></td>
  162.           <td>
  163.             <img src="images/spacer.gif" width="16" height="1" alt=""></td>
  164.           <td>
  165.             <img src="images/spacer.gif" width="120" height="1" alt=""></td>
  166.           <td>
  167.             <img src="images/spacer.gif" width="19" height="1" alt=""></td>
  168.           <td>
  169.             <img src="images/spacer.gif" width="96" height="1" alt=""></td>
  170.           <td>
  171.             <img src="images/spacer.gif" width="23" height="1" alt=""></td>
  172.           <td>
  173.             <img src="images/spacer.gif" width="21" height="1" alt=""></td>
  174.           <td>
  175.             <img src="images/spacer.gif" width="1" height="1" alt=""></td>
  176.           <td>
  177.             <img src="images/spacer.gif" width="11" height="1" alt=""></td>
  178.           <td>
  179.             <img src="images/spacer.gif" width="77" height="1" alt=""></td>
  180.           <td>
  181.             <img src="images/spacer.gif" width="10" height="1" alt=""></td>
  182.           <td>
  183.             <img src="images/spacer.gif" width="20" height="1" alt=""></td>
  184.           <td>
  185.             <img src="images/spacer.gif" width="19" height="1" alt=""></td>
  186.           <td>
  187.             <img src="images/spacer.gif" width="14" height="1" alt=""></td>
  188.           <td>
  189.             <img src="images/spacer.gif" width="104" height="1" alt=""></td>
  190.           <td>
  191.             <img src="images/spacer.gif" width="36" height="1" alt=""></td>
  192.           <td>
  193.             <img src="images/spacer.gif" width="163" height="1" alt=""></td>
  194.           <td>
  195.             <img src="images/spacer.gif" width="8" height="1" alt=""></td>
  196.           <td>
  197.             <img src="images/spacer.gif" width="52" height="1" alt=""></td>
  198.           <td>
  199.             <img src="images/spacer.gif" width="6" height="1" alt=""></td>
  200.           <td>
  201.             <img src="images/spacer.gif" width="22" height="1" alt=""></td>
  202.           <td>
  203.             <img src="images/spacer.gif" width="126" height="1" alt=""></td>
  204.           <td>
  205.             <img src="images/spacer.gif" width="9" height="1" alt=""></td>
  206.           <td></td>
  207.           </tr>
  208.       </table>
  209.     </div>
  210.   </div>
  211. </div>
  212. <!-- End Save for Web Slices -->
  213. </body>
  214. </html>
Can someone please tell me what I'm doing wrong or not seeing?

Thank you

Dec 13 '10 #1
10 2613
Bryan Cheung
55 New Member
This is bad HTML, you should consider making the HTML en CSS yourself and not let Photoshop do this. Photoshop is a great image editing software but not for development.

And tables are not meant to be used for layout construction, you make divisions with the <div>-tag.

First convert your layout to a semantic layout and then we'll be able to help you much better.

Dec 14 '10 #2
1,206 Recognized Expert Top Contributor
What browser are you viewing this in? If IE provide the version as well.
Dec 14 '10 #3
347 Contributor

Unfortunately since this is a psd file that I had to convert, there's really not a lot I can do about the html that's generated. I'm limited to that because I have to convert the psd file to html.

JKing, the version is IE 8 in Windows 7.
Dec 14 '10 #4
1,206 Recognized Expert Top Contributor
I can't replicate the issue unfortunately. The align="center" on the table should be enough to keep your page centered. Centers for me in both FF and IE8.

Is this a resolution issue for some users?
Dec 14 '10 #5
Bryan Cheung
55 New Member
Expand|Select|Wrap|Line Numbers
  1. <div class="css" id="site_layout.css">
Thats just not right..

Expand|Select|Wrap|Line Numbers
  1. <div id="site_layout">
If this doesn't help, do you have a online example?

Dec 14 '10 #6
347 Contributor

I have this

Expand|Select|Wrap|Line Numbers
  1. <div id="container">
  2.   <div id="site_layout">
  3.     <div class="css" id="site_layout.css">
so you're saying to combine div id and div class together?
Dec 14 '10 #7
Bryan Cheung
55 New Member
No, your usage of the id of the div is wrong.
-"site_layout.cs s" is the name of your css file
-your id in your css is #site_layout so your syntax should be: <div id="site_layout "> that how you set a id on a div.
-why calling your div class "css", no idea. Its a bad practice usage, use more describing names.


Link: http://www.w3schools.com/css/css_id_class.asp

More direct link: http://www.w3schools.com/css/tryit.a...ycss_syntax_id
Dec 14 '10 #8
347 Contributor

the resolution on the computer in question is 1680x1050.
Dec 14 '10 #9
347 Contributor
I fixed it with the code that you sent Bryan. Thank you.
Dec 14 '10 #10

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

Similar topics

by: George Ziniewicz | last post by:
.. I try to use CSS when possible, though I am still learning and don't maximize its use. In particular, I still use a table to provide for a centered image in a few slideshows (though table vertical align doesn't work in Mozilla): http://zintel.com/homepics.html I've used combinations of <center>, style align 'center', table cell align, valign and height='100%' to get what I want, but I wonder if CSS can do it by itself.
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
by: Kenneth | last post by:
Okay, I've been scouring Google for hours looking for a solution to this problem, but as of yet I can't find one. XHTML Transitional seems to specify that I can no longer set a table's height to 100% and vertically center content inside of it. Therefore, I'm seeking a way, preferably in CSS to vertically center a site. Here's more of a visual to what I have: /********************************
by: yawnmoth | last post by:
I'm trying to center list elements in a webpage I'm working on, and setting margin-left to auto for ol (or ul) seems to prevent the number (or bullet) from displaying in IE6 (strict mode) and Opera7 (it works fine in Firefox). Any ideas as to why and what I might do to fix it? I've set up a little demonstration of the problem here: http://www.frostjedi.com/terra/dev/test.html It's set up to render in quirks mode to demonstrate that it...
by: autogoor | last post by:
I have a table and, in one cell of it, I have another table. How can I center the second table in the cell with css? Thanks, autogoor
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up doing this demo with tables. The main problems are the vertical centering of the info area, and of the text inside the squares.
by: Neal | last post by:
http://www.brassattackofspringfield.com/gigs.html CSS at http://www.brassattackofspringfield.com/default.css Opera and IE render caption as desired. Firefox does not. Why? And is there a fix?
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. Any idea why? Thanks in advance!
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
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,...
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...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.