Centring tables using CSS
Moderator: General Moderators
Centring tables using CSS
I suppose it's about time that all my pages meet HTML 4.01 standard, before learning XHTML or XML. I notice on W3C that the <center> tag and align attribute in <table> are depricated. I guess I need to do it using style sheets. So, how do I centre a table this way?
Thanks.
Thanks.
You can't, use
Code: Select all
<div align="center"></div>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To do the same thing using CSS:
or set up a class in your stylesheet
and use that
Never say never Takuma
Mac
Code: Select all
<div style="text-align: center;">Insert table here</div>Code: Select all
.aligncenter {text-align: center;}Code: Select all
<div class="aligncenter">Insert table here</div>Mac
This may be of some help:
But it will obvoisly just align all tables on the page.
Code: Select all
table {
align: center;
}- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
First of all in CSS it should be:
not
and secondly you can't align your tables like that, you need to put them in divs if you want to align them on the page.
Mac
Code: Select all
text-align: center;Code: Select all
align: center;Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Why do you think this doesn't work?
Code: Select all
<!-- TABLE STUFF -->
<td style="text-align: center;">Hello</td>
<!-- TABLE STUFF -->- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK