# CENTER tag deprecated in HTML 4.01 - what now?



## pyritechips (Jun 3, 2002)

Since this very handy tag is to be excluded from HTML and future browser versions, how the heck do you easily center tables, TR and TD, etc.? 

I've reading up on CSS on the W3 site but they don't clearly demonstrate how to center elements. I can't find an easy method at other sites I've Googled either.

Any ideas?


----------



## Shadow2531 (Apr 30, 2001)

Use css

table {margin-left: auto; margin-right: auto}

You have to use a proper doctype or it will not work in IE because IE will not be in standards mode.

You can do it the same way as this div .

You can also use margin: 0px auto;


----------



## pyritechips (Jun 3, 2002)

Thx shadow: I guess I still have a lot to learn. I will study the source code of your div example -thanks kindly! I just think ​ was a heck of a lot easier. I wonder why they changed it?


----------



## Shadow2531 (Apr 30, 2001)

Here's another example with an actual table.

http://home.tbbs.net/shadow/tsgforums/csscenteredtable.html

Go ahead and validate it too.

If you do not have a valid doctype, you can use the auto margins and then use div.c1{text-align: center} for IE.

for example

Your table

It's just recommended to use a valid doctype so IE will work with the auto margins.

The auto margins method is not a hack, it's the w3c recommenedation for centering.


----------



## Corrosive (Jan 9, 2003)

Isn't still okay-ish to use? I use the CSS method myself; just a bit curious.


----------



## pyritechips (Jun 3, 2002)

Corrosive:

This is a quote from the W3 site: http://www.w3schools.com/tags/tag_div.asp


> Differences Between HTML and XHTML
> The "align" attribute of the div element was deprecated in HTML 4.01.
> 
> The "align" attribute of the div element is not supported in XHTML 1.0 Strict DTD.


----------



## Snake~eyes (Apr 18, 2002)

> _Originally posted by Corrosive:_
> *Isn't still okay-ish to use? I use the CSS method myself; just a bit curious.  *


bah, they need to stop depreciating stuff


----------



## Shadow2531 (Apr 30, 2001)

> _Originally posted by Corrosive:_
> *Isn't still okay-ish to use? I use the CSS method myself; just a bit curious.  *


Yes, it isn't still okay-ish in terms of w3c, but you can go ahead and still use it. I won't diss you.

I've almost always used XHMTL and never really depended on


----------

