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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

valign center 1

Status
Not open for further replies.

new2this2002

Programmer
Jun 22, 2002
67
GB
I have the following code.....

Code:
<table cellspacing="0" width="100%">
<tr>
<td width="25%" valign="middle"></td>
<td width="50%" valign="middle">content</td>
<td width="25%" align="right" valign="middle">
<div>
<form>
<p>
<select>
<option value="original" selected="selected">original</option>
</select>
</p>
</form>
</div>
</td>
</tr>
</table>

when i view this table in IE the combo box is anchored to the top of the table cell...but when i view the page in Netscape or FireFox it is vertically aligned in the center of the table cell. Does anyone have any clues as to why this might be as the 'content' is vertically aligned in the center is all the browsers, i assume i have something missing with the DIV tag...
 
Actually, it's doing exactly what you told it to do. I would say that IE isn't liking the valign attribute.

There's always a better way. The fun is trying to find it!
 
it must like the 'valign' attribute otherwise the 'content' would not be vertically centered
 
Form is the highest element in a table, and IE adds some bottom margin on it. If you set form style to "border: 0px" or "display: inline" things should be centered vertically.
 
i have added

Code:
<form style="margin:0px;border:0px;display:inline">

that now vertically aligns the combo box in the center...but the 'content' is now vertically aligned at the top
 
apologies....i omitted some information...after adding the

Code:
<form style="margin:0px;border:0px;display:inline">

the size of the table shrunk in height so i added...

Code:
<td width="50%" valign="middle">content<br /><br /></td>

which vertically centered the combo box...but sent the 'some content' to the top
 
Here is somewhat cleaner approach:
Code:
<table cellspacing="0" width="100%" border="1">
<tr style="height: 100px; vertical-align: middle;">
	<td width="25%">blah</td>
	<td width="50%">content</td>
	<td width="25%" align="right">
<form style="margin: 0px;">
	<select>
		<option value="original" selected="selected">original</option>
	</select>
</form>
	</td>
</tr>
</table>
 
well that certainly sorted it and gave me some nicer code....thanks very much for the quick repsonses and help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top