Link to home
Start Free TrialLog in
Avatar of John500
John500Flag for United States of America

asked on

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
Avatar of edster9999
edster9999
Flag of Ireland image


         <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

ASKER CERTIFIED SOLUTION
Avatar of edster9999
edster9999
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John500

ASKER

Thanks, I was able to get something from each of your posts.