To place the table in center, we can use <table align="center"> in HTML 4, but in xHTML the 'align' is not allowed. So how to place the table in the center by using the CSS? Even the Horizontal Rule <hr> needs to be aligned in the center.. Please help me in this regard. I am currently using xHTML Transitional which allows 'align' attributes.. But I want to try using Strict and this does not allow 'align' atribute. Please tell me how to place the table in center in xHTML 1 with Strict DTD..
You can use CSS to center things. All things presentational should be put inside your CSS, hence why things like the center tag have deprecated as it can be done inside CSS. To center text you use text-align:center; To center an element you use margin:0 auto; <table style="margin:0 auto;"> Or reccomended give the table a class <table class="styletable"> Then refer to it inside your external CSS sheet like so: .styletable { margin:0 auto; text-align:center; } My guess is you are using a table for a layout, which isn't reccomended as much any more as it's often reccomened to use DIV's to create your layout Also HR isn't reccomened any more as with padding, margins + backgrounds you can re-create anything the HR did in the first place. So you can add this CSS inline to your table like:
So 'margin:0 auto;' is the best thing to center the items using CSS.. I had tried using horizontal-align or the text-align in a div as said by amazingronit and ceetoe long before. But it did not align a table into center position.. It will align the text inside a table into centered position.. Thats why I asked this doubt here.. Using <center> tags and align="center" attributes is not recommended in xHTML. Thanks a Lot guys.. Have a great time..