Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table align="center" doesn't seem to be working

Tags:

html

css

Why would the align="center" not be working on the first table on the page below:

http://eurochlor.amaze.com/chlorinated-solvents-%28ecsa%29/about-chlorinated-solvents/facts-figures/trichloroethylene.aspx

like image 211
Burt Avatar asked Aug 18 '11 10:08

Burt


People also ask

Why does Align Center doesn't work?

Why does Align Center doesn't work? Short answer: your text isn't centered because the elements are floated, and floated elements "shrink" to the content, even if it's a block level element.

How do I center align data in a table?

We use the CSS property text-align, to center align text in table cells. We use inline, internal style sheet for text alignment in table cells. The text-align property of CSS sets the alignment of the content in <th> and <td>. By default, the content of <th> are center-aligned and the content of <td> are left-aligned.

How do I get the TH Align Center?

HTML | <th> align Attribute right: It sets the text right-align. center: It sets the text center-align. justify: It stretches the text of paragraph to set the width of all lines equal. char: It sets the text-align to a specific character.

How do you fix aligned tables in HTML?

Table data defaults to left alignment; table headers to center. In order to change the alignment in one cell, insert the appropriate "ALIGN=" attribute within the code for that cell. In order to change the alignment in all cells in a row, insert the appropriate alignment attribute within the code for that row.


2 Answers

If you want to have the table centered use:

.content-table {
    margin: 0 auto;
}

if you want to have the td text centered use:

.content-table td {
    text-align: center;
}
like image 121
Sascha Galley Avatar answered Oct 08 '22 19:10

Sascha Galley


You should use CSS selector with Attribute align="center" like below:

table[align="center"] {
    margin: 0 auto;
}
like image 23
kollein Avatar answered Oct 08 '22 18:10

kollein