How to center a button on web page ?

I have a web page (see picture below) which uses a submit button.  I'm having problems centering this button in the middle of the page.

For the code which includes the 'Comments' & 'Submit' button see the snippet below.

How would this code have to change to center the button??  

Thanks!
<table style="width: 100%" border="0" cellspacing="0" cellpadding="0" id="MainTable" runat="server">
        <tr>
        ...
        ...
        <tr>
            <td colspan="1" style="height: 37px; width: 159px;"> Comments:</td>
            <td colspan="2" style="height: 37px; width: 240px;">
                <asp:TextBox id="TBComment" runat="server" Width="630px" Height="50px" TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr> 
         <tr> 
            <td valign="top" style="height: 4px; width: 159px;"> &nbsp;</td>
        </tr>
         <tr>
            <td colspan="3" align="center" valign="middle" style="height: 2px; width: 259px;"> 
                &nbsp;<asp:Button ID="BSubmit" runat="server" Text="Submit" Width="103px" BorderStyle="Groove" OnClick="BSubmit_Click" TabIndex="26" /></td>
        </tr>        
    </table>

Open in new window

UserModTable.JPG
John500Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

edster9999Commented:

         <tr>
            <td colspan="3" align="center" valign="middle" style="height: 2px; width: 259px;"> 
                 <center><asp:Button ID="BSubmit" runat="server" Text="Submit" Width="103px" BorderStyle="Groove" OnClick="BSubmit_Click" TabIndex="26" /></center></td>
        </tr>      

Open in new window

0
edster9999Commented:
you also need to make sure all rows have 3 TDs in them.
This can be done with 3 different <td>text</td>
or using colspan (as you have above).
The one that stands out as wrong is

         <tr>
            <td valign="top" style="height: 4px; width: 159px;">  </td>
        </tr>

This should have colspan="3" in it

also.... you should always have 'something' other than spaces inside a table row or some browsers will not print it so in the space you should do &nbsp;

so it becomes ...

         <tr>
            <td colspan="3" valign="top" style="height: 4px; width: 159px;">&nbsp;</td>
        </tr>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
the_bachelorCommented:
your problem was the width: 259px; property that you have in the styling of the <td></td> tags where you had your submit button. Taking that out is a good start
<table style="width: 100%" border="0" cellspacing="0" cellpadding="0" id="MainTable" runat="server">
        <tr>
        ...
        ...
        <tr>
            <td colspan="1" style="height: 37px; width: 159px;"> Comments:</td>
            <td colspan="2" style="height: 37px; width: 240px;">
                <asp:TextBox id="TBComment" runat="server" Width="630px" Height="50px" TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr> 
         <tr> 
            <td valign="top" style="height: 4px; width: 159px;"> &nbsp;</td>
        </tr>
         <tr>
            <td colspan="3" align="center" valign="middle" style="height: 2px;"> 
                &nbsp;<asp:Button ID="BSubmit" runat="server" Text="Submit" Width="103px" BorderStyle="Groove" OnClick="BSubmit_Click" TabIndex="26" /></td>
        </tr>        
    </table>

Open in new window

0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Anurag ThakurTechnical ManagerCommented:
try this code it works
the colspan int eh td in line no 12 was also missing & i have also removed the width inthe td on line 15 as suggested by both the above authors
<table id="MainTable" runat="server" border="1" cellpadding="0" cellspacing="0" style="width: 100%">
	<tr>
	</tr>
	<tr>
		<td colspan="1" style="height: 37px; width: 159px;">
			Comments:
		</td>
		<td colspan="2" style="height: 37px; width: 240px;">
			<asp:TextBox ID="TBComment" runat="server" Height="50px" TextMode="MultiLine" Width="630px"></asp:TextBox>
		</td>
	</tr>
	<tr>
		<td colspan="3" style="height: 4px; width: 159px;" valign="top">
		</td>
	</tr>
	<tr>
		<td align="center" colspan="3" style="height: 2px;" valign="middle">
			<asp:Button ID="BSubmit" runat="server" BorderStyle="Groove" OnClick="Button_Click" TabIndex="26" Text="Submit" />
		</td>
	</tr>
</table>

Open in new window

0
edster9999Commented:
Well if you want to be VERY precise you cannot have a <tr> and </tr> without anything in them (so I've dropped that)

No point in having a colspan="1" - so I've dropped that

The colspan3 line is too short (although most browsers would pad it out) so I stretched that to the wdith of the 2 cells above (399)

<table id="MainTable" runat="server" border="1" cellpadding="0" cellspacing="0" style="width: 100%">
        <tr>
                <td style="height: 37px; width: 159px;">
                        Comments:
                </td>
                <td colspan="2" style="height: 37px; width: 240px;">
                        <asp:TextBox ID="TBComment" runat="server" Height="50px" TextMode="MultiLine" Width="630px"></asp:TextBox>
                </td>
        </tr>
        <tr>
                <td colspan="3" style="height: 4px; width: 399px;" valign="top">
                </td>
        </tr>
        <tr>
                <td align="center" colspan="3" style="height: 2px;" valign="middle">
                        <asp:Button ID="BSubmit" runat="server" BorderStyle="Groove" OnClick="Button_Click" TabIndex="26" Text="Submit" />
                </td>
        </tr>
</table>

Open in new window

0
John500Author Commented:
Thanks, I was able to get something from each of your posts.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.