Hoe een tabel centreren
- Previous page Zebra-stripe table
- Next page Full-width table
Leer hoe je een tabel centreren met CSS.
Centraal geplaatste tabel:
Voornaam | Achternaam | Leeftijd |
---|---|---|
Jill | Smith | 50 |
Eve | Jackson | 94 |
John | Doe | 80 |
Hoe een tabel centreren
Stap 1 - Voeg HTML toe:
<table class="center"> <tr> <th>Voornaam</th> <th>Achternaam</th> <th>Leeftijd</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> <tr> <td>John</td> <td>Doe</td> <td>80</td> </tr> </table>
Stap 2 - Voeg CSS toe:
Om de tabel centreren, stel de linker en rechter marges in op automatisch:
.center { margin-left: auto; margin-right: auto; }
Note that if the width is set to 100% (full width), the table cannot be centered.
Related pages
Tutorial:CSS table
- Previous page Zebra-stripe table
- Next page Full-width table