The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How do I center tables on HTML page?, How do I center tables on HTML page?
plowter
post Oct 21 2006, 08:37 AM
Post #1





Group: Members
Posts: 1
Joined: 21-October 06
Member No.: 509



How do I center a table-based layout on a variable width page?

Want a table-based layout to test a design, don't want to use CSS. Am using a table as the overall container for the page, so this method works fine.

<CENTER>
<TABLE ...> // overall page container table
<TR>
...
</TR>
</TABLE>
</CENTER>

However, the validator says that <CENTER> is depricated in HTML 4.01. How do I center this container table, without using CSS?

Thanks
plowter
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 21 2006, 08:48 AM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 13,731
Joined: 9-August 06
Member No.: 6



I don't see how using one line of CSS could hurt you, but if you are dead against it use a doctype that allows deprecated elements and attributes. You should anyway, because if you don't use CSS I suspect CENTER isn't the only thing deprecated in your HTML.


--------------------
“Never go to excess, but let moderation be your guide.”
– Cicero

IPB Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post Oct 21 2006, 11:47 AM
Post #3


Serious Contributor
******

Group: Members
Posts: 780
Joined: 24-August 06
From: t-dot
Member No.: 16



What's pady's saying is that to allow deprecated elements like CENTER you could use a transitional instead of strict doctype.

He doesn't really believe much in that advice though. happy.gif
For reasoning behind that belief . . . http://hsivonen.iki.fi/doctype/
and more opinion in this thread

This post has been edited by jimlongo: Oct 21 2006, 11:54 AM


--------------------
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 21 2006, 12:32 PM
Post #4


.
********

Group: WDG Moderators
Posts: 4,776
Joined: 10-August 06
Member No.: 7



QUOTE(plowter @ Oct 21 2006, 03:37 PM) *

However, the validator says that <CENTER> is depricated in HTML 4.01. How do I center this container table, without using CSS?


CENTER is deprecated exactly because W3C wants people to use CSS instead. In other words, if you don't want CSS you are almost per definition writing your web pages in a deprecated fashion unless you avoid all decorations. In fact W3C doesn't want us to use tables for layout either, only for tabular data. tongue.gif

Otherwise you could use a 100% wide three-column layout table, and put the content in the center column.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
metsatöll
post Oct 22 2006, 01:30 PM
Post #5





Group: Members
Posts: 1
Joined: 22-October 06
Member No.: 520



CODE


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>

<style type="text/css">
body {
      background: #000;  
}
#wrap {
     margin: 0 auto; /* margin 0 auto will center that box in your document */
     width: 780px; /*size of your box*/
     background: #fff;
     text-align: center; /* everything will be written in that box will be centered horizontaly*/
     }
</style>
</head>
<body>


<div id="wrap">
  <table width="780">
     <tr>
        <td align="left">
                   content goes here
        </td>
     </tr>
   </table>
</div>


</body>
</html>


hint: Div box wont be centered in IE incase of removed doctype wink.gif

This post has been edited by metsatöll: Oct 22 2006, 01:33 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th May 2013 - 07:22 PM