Help:Tables: Difference between revisions

m Protected "Help:Tables": High-traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
 
Line 162: Line 162:
|Cell 5
|Cell 5
|style="text-align:center"|Cell 6
|style="text-align:center"|Cell 6
|}
|}
===Centering columns===
If you want to center all cells in a specific column, it can be a bit of a pain to add <code>style="text-align:center"</code> to every cell in that column, so this wiki has special CSS classes that you can add to the table classes to center all cells in a specific column automatically. Use <code>center-col-X</code> and replace X with a number for the column.
{|class="wikitable"
!Wikitext
!Result
|-
|<pre>{|class="wikitable center-col-2"
!Header 1 !! Header 2 !! Header 3
|-
|Cell 1 || Cell 2 || Cell 3
|-
|Cell 4 || Cell 5 || Cell 6
|-
|Cell 7 || Cell 8 || Cell 9
|}</pre>
|
{|class="wikitable center-col-2"
!Header 1 !! Header 2 !! Header 3
|-
|Cell 1 || Cell 2 || Cell 3
|-
|Cell 4 || Cell 5 || Cell 6
|-
|Cell 7 || Cell 8 || Cell 9
|}
|}
|}
|}