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

How do I center a table vertically on an html page? 1

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
The attribute "valign" is not valid for a table element.
Please advise.
 
Valign works for me here's a way to centre your table as well.
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="screen">
/* commented backslash hack for ie5mac \*/ 
html, body{height:100%;} 
/* end hack */
#main{
 position: absolute;
 left: 50%;
 top: 50%;
 margin-top: -50px; /* make this half your element height */
 margin-left: -50px; /* make this half your element width */
border: 1px solid #FF0000;
width:100px;
height:100px;
}
</style>

</head>
<body >
<div id="main" ><Table id = "go" width = "100%"  height = "100%"  border = "3"><tr><td align = "center" valign = "middle"> test</td></tr></table></div>
</body></html>

Glen
 
Or this
Code:
<table [COLOR=red]width="100%" height="100%"[/color]>
 <tr>
  <td align="center" valign = "middle" >Your content goes here<br/> this could be another table if you wish</td>
</tr>
</table>



Glen
 
Your second solution was a great idea. It is a simple, elegant solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top