Help:Introduction to tables with Wiki Markup/2: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Gadget850 (talk | contribs)
ce
m ce. I don't think we need another help page on the Wikitable class, it's fairly simple.
Line 60: Line 60:
'''wikitable'''
'''wikitable'''


<code>class="wikitable"</code> is used with a lot of tables and adds styling. For details, see [[Help:Wikitable class]].
<code>class="wikitable"</code> is used with a lot of tables on Wikipedia and adds some standard styling.


'''border'''
'''border'''


Even though the <code>wikitable</code> class includes a border, it is a good practice to include <code>border="1"</code>. If the page with the table is ported to another wiki without the <code>wikitable</code> class, then the table will have no borders without it.
Even though the <code>wikitable</code> class includes a border, it is a good practice to also include <code>border="1"</code>. If the page with the table is ported to another wiki without the <code>wikitable</code> class, then the table will have no borders without it.


{{Help intro next |target=Help:Table/Sortable tables}}
{{Help intro next |target=Help:Table/Sortable tables}}

Revision as of 16:14, 7 March 2013

Editing tables
The basics

Expanding tables
Adding rows and columns

Summary
Review of what you've learned


If you don't have a way of creating tables automatically, or want more control over them, this tutorial should explain how. So, a basic table, as discussed, is:

{| class="wikitable" border="1"
|-
! header 1
! header 2
! header 3
|-
| row 1, cell 1
| row 1, cell 2
| row 1, cell 3
|-
| row 2, cell 1
| row 2, cell 2
| row 2, cell 3
|}

As you can see, columns headers are created by ! column name. Cells are created by | cell text. The divider between rows is |-. You can add an extra column by just sticking ! new column name at the end of the last column name. To fill the cells in that column, you need to add another cell to each row: fill it by typing |cell text. If you want to add an extra row, just add |- to the table, and fill it with however many cells are appropriate.

To recap, the markup is:

{|

table start

|+

table caption, optional; only between table start and first table row

|-

table row, optional on first row; wiki engine assumes the first row

!

table header cell, optional. Consecutive table header cells may be added on same line separated by double marks (!!) or start on new lines, each with its own single mark (!).

|

table data cell, required! Consecutive table data cells may be added on same line separated by double marks (||) or start on new lines, each with its own single mark (|).

|}

table end
  • The above markup must start on a new line except the double || and !! for optionally adding consecutive cells to a line. Blank spaces at the beginning of a line are ignored.
  • HTML attributes: All table markup, except table end, optionally accepts one or more HTML attributes on the same line.
    • Cells and caption (| or ||, ! or !!, and |+) hold content. So separate any attributes from content with a single pipe (|). Cell content may follow on same line or on following lines.
    • Table and row markup ({| and |-) do not directly hold content. Do not add pipe (|) after their optional attributes. If a pipe is added improperly after attributes for the table or row markup, the parser will delete it and any final attribute that was touching the improper pipe.
  • Content may follow its cell markup on the same line after any optional HTML attributes or on lines below the cell mark. Content that uses wikimarkup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.
  • Escaping to insert a pipe (|) character into a table use the <nowiki> markup

wikitable

class="wikitable" is used with a lot of tables on Wikipedia and adds some standard styling.

border

Even though the wikitable class includes a border, it is a good practice to also include border="1". If the page with the table is ported to another wiki without the wikitable class, then the table will have no borders without it.