CZ:How to make tables: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Derek Harkness
(A little more info, still rather basic.)
imported>J. Noel Chiappa
(→‎Wikicode: Clarify a bit)
 
(13 intermediate revisions by 6 users not shown)
Line 1: Line 1:
There are two ways to build '''tables''':
There are two ways to build '''tables''':


*in special Wiki-markup
* In special Wiki-markup
*with HTML elements: <nowiki><table>, <tr>, <td> or <th></nowiki>.  
* With HTML elements: <nowiki><table>, <tr>, <td> or <th></nowiki>.  


==Simple example==
==Markup description==
<table class="wikitable">
 
<tr><th>Sex</th><th>Height<th>Weight</tr>
===Wikicode===
<tr><td>Males</td><td>1.85</td><td>100</td></tr>
A table is started with the code <B><nowiki>{|</nowiki></b>, and ended with the code <b><nowiki>|}</nowiki></b>.
<tr><td>Females</td><td>1.6</td><td>75</td></tr>
 
</table>
At the point at which the table is started, you can specificy specific style elements about your table, such as
* having a border (by adding border="1")
* setting border colors
* setting table width
* other CSS elements
 
<!-- How? -->
 
The start of a new row (including the header row) is marked by <b><nowiki>|-</nowiki></b>.
 
The table header cells in the header row are denoted (and delineated) by an exclamation mark: <b><nowiki>!</nowiki></b>
 
The start of the first cell in a normal row is marked by <b><nowiki>|</nowiki></b>. Cells within a row are separated by a line break and a <b><nowiki>|</nowiki></b> (or a double <b><nowiki>|</nowiki></b>, if on the same line).
 
At this point, you can also
* specify the alignment of the cell
* specify how many columns it will cover
* apply other CSS style elements
 
<!-- How? -->
 
Additional spaces and line breaks within the table code are ignored. So both of the following code fragments produce the same result:
 
<nowiki>
|-
| Female
| 1.6
| 75
 
and:
 
|-
| Female || 1.6 || 75
</nowiki>
 
===HTML===
An HTML table is started with the code <b><nowiki><table></nowiki></b> and ended with the code <b><nowiki></table></nowiki></b>
A new row is started by <b><nowiki><tr></nowiki></b> and ended by <b><nowiki></tr></nowiki></b> (end tags may be optional.)
Cells within rows that are headers for the table are started <b><nowiki><th></nowiki></b> and ended by <b><nowiki></th></nowiki></b> (end tags may be optional.)
Cells within rows contain the table data are started <b><nowiki><td></nowiki></b> and ended by <b><nowiki></td></nowiki></b> (end tags may be optional.)
Additional spaces and line breaks within the table code are ignored. So both of the following code fragments produce the same result:
 
<nowiki>
<tr>
    <td>Females</td>
    <td>1.6</td>
    <td>75</td>
</tr>
</nowiki><br />
and      <br />
<nowiki><tr><td>Females</td><td>1.6</td><td>75</td></tr></nowiki>
 
== Advanced editing ==
There are many additional things that can be done with tables. Full explanations of every feature of the HTML table markup can be found at the [http://www.w3.org/TR/html401/struct/tables.html| w3.org specifications] and at [http://www.w3schools.com/html/html_tables.asp| w3schools.com].
 
== Simple examples ==
 
The following two examples produce the same table (given at the bottom):


===Wiki-markup===
===Wiki-markup===
  <nowiki>{| class="wikitable"</nowiki><br />
  <nowiki>
  <nowiki>|-</nowiki><br />
{| class="wikitable"
  <nowiki>! Sex</nowiki><br />
  |-
  <nowiki>! Height</nowiki><br />
  ! Sex
  <nowiki>! Weight</nowiki><br />
  ! Height
  <nowiki>|-</nowiki><br />
  ! Weight
  <nowiki>| Male</nowiki><br />
  |-
  <nowiki>| 1.85</nowiki><br />
  | Male
  <nowiki>| 100</nowiki><br />
  | 1.85
  <nowiki>|-</nowiki><br />
  | 100
  <nowiki>| Female</nowiki><br />
  |-
  <nowiki>| 1.6</nowiki><br />
  | Female
  <nowiki>| 75</nowiki><br />
  | 1.6
  <nowiki>|}</nowiki><br />
  | 75
  |}
</nowiki>


===HTML===
===HTML===
Line 34: Line 93:
  <nowiki></table></nowiki><br />
  <nowiki></table></nowiki><br />


==Markup description==
===Product===
===Wikicode===
Table is starte with the code <nowiki>{|</nowiki> and ended witht the code <nowiki>{|</nowiki>
The divition of rows is marked by <nowiki>|-</nowiki>
The talbe header cells are denoted by an exclamation mark <nowiki>!</nowiki>
Cells within rows are separated by a pipe <nowiki>|</nowiki> on it's own.
Additional spaces and line breaks within the table code are ignored. So both of the following code fragments produce the same result


<nowiki>|-</nowiki><br />
<table class="wikitable">
<nowiki>| Female</nowiki><br />
<tr><th>Sex</th><th>Height<th>Weight</tr>
<nowiki>| 1.6</nowiki><br />
<tr><td>Males</td><td>1.85</td><td>100</td></tr>
<nowiki>| 75</nowiki><br />
<tr><td>Females</td><td>1.6</td><td>75</td></tr>
 
</table>
is the same as
 
<nowiki>|-</nowiki><br />
<nowiki>| Female | 1.6 | 75 </nowiki><br />
 
===HTML===
Table is starte with the code <nowiki><table></nowiki> and ended witht the code <nowiki></table</nowiki>
A new row is started by <nowiki><tr></nowiki> and ended by <nowiki></tr></nowiki> (end tags may be optional.)
Cells within rows that are headers for the table are started <nowiki><th></nowiki> and ended by <nowiki></th></nowiki> (end tags may be optional.)
Cells within rows contain the table data are started <nowiki><td></nowiki> and ended by <nowiki></td></nowiki> (end tags may be optional.)
Additional spaces and line breaks within the table code are ignored. So both of the following code fragments produce the same result:
 
<nowiki><tr></nowiki><br />
<nowiki>   <td>Females</td></nowiki><br />
<nowiki>  <td>1.6</td></nowiki><br />
<nowiki>  <td>75</td></nowiki><br />
<nowiki></tr></nowiki><br />
 
is the same as


<nowiki><tr><td>Females</td><td>1.6</td><td>75</td></tr></nowiki><br />


====Advanced editing====
{{Technical Help}}
There are many additional things that can be don with tables. Full explanations of every feature of the HTML table markup can be found at the [http://www.w3.org/TR/html401/struct/tables.html| w3.org specificats] and at [http://www.w3schools.com/html/html_tables.asp| w3schools.com].

Latest revision as of 23:46, 28 April 2008

There are two ways to build tables:

  • In special Wiki-markup
  • With HTML elements: <table>, <tr>, <td> or <th>.

Markup description

Wikicode

A table is started with the code {|, and ended with the code |}.

At the point at which the table is started, you can specificy specific style elements about your table, such as

  • having a border (by adding border="1")
  • setting border colors
  • setting table width
  • other CSS elements


The start of a new row (including the header row) is marked by |-.

The table header cells in the header row are denoted (and delineated) by an exclamation mark: !

The start of the first cell in a normal row is marked by |. Cells within a row are separated by a line break and a | (or a double |, if on the same line).

At this point, you can also

  • specify the alignment of the cell
  • specify how many columns it will cover
  • apply other CSS style elements


Additional spaces and line breaks within the table code are ignored. So both of the following code fragments produce the same result:

 |-
 | Female
 | 1.6
 | 75

and:

 |-
 | Female || 1.6 || 75 

HTML

An HTML table is started with the code <table> and ended with the code </table> A new row is started by <tr> and ended by </tr> (end tags may be optional.) Cells within rows that are headers for the table are started <th> and ended by </th> (end tags may be optional.) Cells within rows contain the table data are started <td> and ended by </td> (end tags may be optional.) Additional spaces and line breaks within the table code are ignored. So both of the following code fragments produce the same result:

 <tr>
    <td>Females</td>
    <td>1.6</td>
    <td>75</td>
 </tr>
 
and
<tr><td>Females</td><td>1.6</td><td>75</td></tr>

Advanced editing

There are many additional things that can be done with tables. Full explanations of every feature of the HTML table markup can be found at the w3.org specifications and at w3schools.com.

Simple examples

The following two examples produce the same table (given at the bottom):

Wiki-markup

 {| class="wikitable"
 |-
 ! Sex
 ! Height
 ! Weight
 |-
 | Male
 | 1.85
 | 100
 |-
 | Female
 | 1.6
 | 75
 |}

HTML

<table border="1px">
<tr><th>Sex</th><th>height</th><th>weight</ht></tr>
<tr><td>Males</td><td>1.85</td><td>100</td></tr>
<tr><td>Females</td><td>1.6</td><td>75</td></tr>
</table>

Product

SexHeightWeight
Males1.85100
Females1.675


Citizendium Technical Help
How to edit an article | Searching | Start article with subpages
The Article Checklist | Subpage template

|width=10% align=center style="background:#F5F5F5"|  |}