How to align all the cells in the center of the table (except the first row of the table) on css?

table tr:not(td):first-child { text-align: center } 
 <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> </table> 

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

 table tr:not(:first-child) td { text-align: center; } 

PS If the phrase " except the first row " meant the first column, then

 table tr td:not(:first-child) { text-align: center; } 

 table { width: 100%; margin-bottom: 15px; border-collapse: collapse; table-layout: fixed; } td { border: 1px solid #999; } table.row tr:not(:first-child) td { text-align: center; background: #ff0; } table.col tr td:not(:first-child) { text-align: center; background: #ff0; } 
 <table class="row"> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> </table> <table class="col"> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> </tr> </table> 

    add

     table tr:first-child td{ text-align:left; }