Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't align button in table cell

Status
Not open for further replies.

fdgsogc

Vendor
Feb 26, 2004
160
CA
I have a button in a table cell that won't vertically align to the middle. In fact it won't respond to any align code. I've tried putting valign="middle" in the <td> tag. I've tried using align="middle" in the <input> tag. The button won't budge. Any ideas? Here's the code.
Code:
<table class="display" width="100%" align="left" cellspacing="10" border="1"> 
<tr>
<td align="left" class="projecttitle"> Project:<cfoutput query="getprojectname">&nbsp;#projectname#</cfoutput>
</td>
<td align="right" valign="baseline">
<cfoutput query="getheaderfooter">
<form action="#homelinkactionpage#" method="post">
<input type="button" class="button" value="#homelinktext#" onClick="this.form.submit();" align="bottom">
</form>
</cfoutput>

</td>
</tr></table>
None of my CCS code includes alignment formatting. Here is it.
Code:
.button
{
background-color:#FFFFFF;
font-size:11px
}
td.pagetitle
{
font-family: verdana, arial;
font-size: 30px
}
table.display
{
background-color:#8B181C;
color:#ffffff;
font-size:9px;
font-family: ms sans serif
}
 
Just leave the valign="..." completely out of the <td>. You might need to make the height bigger for the first cell to be able to notice the center alignment, but it does center-align by default:

Code:
<table class="display" width="100%" align="left" cellspacing="10" border="1">
<tr>
<td align="left" class="projecttitle"> Project:<cfoutput query="getprojectname">&nbsp;#projectname#</cfoutput><br>if this row's taller, it'll work. it must just be too short to notice wtihout the extra line...
</td>
<td align="right">
<cfoutput query="getheaderfooter">
<form action="#homelinkactionpage#" method="post">
<input type="button" class="button" value="#homelinktext#" onClick="this.form.submit();" align="bottom">
</form>
</cfoutput>

</td>
</tr></table>

Rick

 
Yeh, all you need to do is to specify a height, and then it will work

JavaScript Beginner at work :)
 
i'm not sure if valign="" will validate as proper xhtml....

the way i would do it is to add
Code:
style="vertical-align: middle;"
to <td>
 
thanks everyone. I've got it working now.

The problem was that my FORM tags were inside the TD tags. Once I placed the FORM tags around the TD tag I was ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top