Difference between revisions for Playground / Table Markup Guide




← Previous edit
Next edit →

Version1 Version2 Differences
1   As of ##6.2##, WackoWiki introduces a flexible markup for data tables. Any kind of tables allowed by HTML5 can be created using this markup, from the most basic examples (e.g. simple rows of cells) to complex tables with full support for accessibility options.
2  
  1 As of **!!(green)6.2!!**, Wacko introduces a flexible markup for data tables. Any kind of tables allowed by HTML5 can be created using this markup, from the most basic examples (e.g. simple rows of cells) to complex tables with full support for accessibility options.
  2  
3 3 {{toc numerate=1}}
4 4
5   ===Table basics: cells, rows, columns===
  5 ===Table basics===
  6 ====Cells====
6 7
7 8 The most basic element of a table is a **cell**. Single cells can be created using the standard delimiter ##""||""##, e.g.:
8 9
18 19
19 20 Note that a cell must always be open and closed by delimiters.
20 21
  22 ====Rows====  
  23  
21 24 **Rows** can be created by adding on the same line multiple cells:
22 25
23 26 %%
29 32 #|
30 33 || Cell 1 | Cell 2 | Cell 3 ||
31 34 |#
  35  
  36 ====Columns====  
32 37
33 38 **Columns** can be created by adding rows on separate lines:
34 39
63 68 |#
64 69
65 70 ===Headings===
66   As soon as you create slightly more complex data tables, you will need to specify column and row **headings**. Headings are special cells that specify what kind of data rows and columns contain. The most basic way of creating a heading is by using ##""^|""## as a delimiter.
67  
68   The following is an example of a simple table with **column headings**:
  71 As soon as you create slightly more complex data tables, you will need to specify column and row **headings**. Headings are special cells that specify what kind of data rows and columns contain. The most basic way of creating a heading is by using ##*|## or ##^|## as a delimiter.
  72
  73 The following is an example of a simple table with **column headings**, they must be terminated at the end of the row with the ##|*## :
69 74
70 75 %%
71 76 #|
79 84 || 300Kg | 480Kg ||
80 85 |#
81 86
82   **Row headings** are created in the same way. Since they are usually followed by normal cells, they must be terminated with the ##""||""## standard delimiter if the next element in the row is a simple cell:
  87 **Row headings** are created in the same way. Since they are usually followed by normal cells, they must be terminated with the ##""|""## standard delimiter if the next element in the row is a simple cell:
83 88
84 89 %%
85 90 #|
117 122
118 123 %%
119 124 #|
120   ?| Fruit production in 2006 |?
  125 ?| Fruit production in 2026 |?
121 126 *| | Apples | Pears |*
122 127 ^| Mary | 300Kg | 320Kg ||
123 128 ^| John | 400Kg | 630Kg ||
125 130 %%
126 131
127 132 #|
128   ?| Fruit production in 2006 |?
  133 ?| Fruit production in 2026 |?
129 134 *| | Apples | Pears |*
130 135 ^| Mary | 300Kg | 320Kg ||
131 136 ^| John | 400Kg | 630Kg ||
132 137 |#
133 138
134   ===Spans===
135   **Spans** are used to combine multiple cells or multiple headings vertically or horizontally and are created using the following [[TableMarkupReference attribute parameters]]:
136  
137   ##""||""(''span options'')Element content""||""##
138  
139   A **cell spanning multiple columns** is generated by prefixing the cell content with a ##(x=''n'')## parameter, where ##''n''## is the number of columns to be spanned. The following example shows how to create a cell spanning two columns:
140  
141   %%
142   #|
143   ||(x=2) Cell spanning 2 columns | Cell 3 ||
  139 ===Cell Spans===
  140 **Cell spans** are used to combine multiple cells or multiple headings vertically or horizontally and are created using the following [[TableMarkupReference attribute parameters]]:
  141
  142 ##""||""(''span options'') Element content ""||""##
  143
  144 A **cell spanning multiple columns** is generated by prefixing the cell content with a ##(colspan=''n'')## parameter, where ##''n''## is the number of columns to be spanned. The following example shows how to create a cell spanning two columns:
  145
  146 %%
  147 #|
  148 ||(colspan=2) Cell spanning 2 columns | Cell 3 ||
144 149 || Cell 4 | Cell 5 | Cell 6 ||
145 150 || Cell 7 | Cell 8 | Cell 9 ||
146 151 |#
147 152 %%
148 153
149 154 #|
150   ||(x=2) Cell spanning 2 columns | Cell 3 ||
  155 ||(colspan=2) Cell spanning 2 columns | Cell 3 ||
151 156 || Cell 4 | Cell 5 | Cell 6 ||
152 157 || Cell 7 | Cell 8 | Cell 9 ||
153 158 |#
154 159
155   Spans can also be applied to rows. A **cell spanning multiple rows** is generated by prefixing the cell content with a ##(y=''n'')## parameter, where ##''n''## is the number of rows to be spanned. The following example shows how to create a cell spanning two rows:
156  
157   %%
158   #|
159   ||(y=2) Cell spanning 2 rows | Cell 2 | Cell 3 ||
  160 Spans can also be applied to rows. A **cell spanning multiple rows** is generated by prefixing the cell content with a ##(rowspan=''n'')## parameter, where ##''n''## is the number of rows to be spanned. The following example shows how to create a cell spanning two rows:
  161
  162 %%
  163 #|
  164 ||(rowspan=2) Cell spanning 2 rows | Cell 2 | Cell 3 ||
160 165 || Cell 5 | Cell 6 ||
161 166 || Cell 7 | Cell 8 | Cell 9 ||
162 167 |#
163 168 %%
164 169
165 170 #|
166   ||(y=2) Cell spanning 2 rows | Cell 2 | Cell 3||
  171 ||(rowspan=2) Cell spanning 2 rows | Cell 2 | Cell 3 ||
167 172 || Cell 5 | Cell 6 ||
168 173 || Cell 7 | Cell 8 | Cell 9 ||
169 174 |#
173 178 %%
174 179 #|
175 180 *| | Mon | Tue | Wed | Thu | Fri |*
176   || 8-9 | |(y=9) Outreach| |(y=9) Outreach | ||
  181 || 8-9 | |(rowspan=9) Outreach | |(rowspan=9) Outreach | ||
177 182 || 9-10 | | | || <-- reduced by two columns
178 183 || 10-11 | | | ||
179 184 || 11-12 | | | ||
180   || 12-1 | | | ||
181   || 1-2 | | | ||
182   || 2-3 |(y=3) CSCI 102 | CSCI 101 | CSCI 101 ||
183   || 3-4 | | || <-- reduced by one column
184   || 4-5 | | ||
  185 || 12-13 | | | ||
  186 || 13-14 | | | ||
  187 || 14-15 |(rowspan=3) CSCI 102 | CSCI 101 | CSCI 101 ||
  188 || 15-16 | | || <-- reduced by one column
  189 || 16-17 | | ||
185 190 |#
186 191 %%
187 192
188 193 #|
189 194 *| | Mon | Tue | Wed | Thu | Fri |*
190   || 8-9 | |(y=9) Outreach| |(y=9) Outreach | ||
  195 || 8-9 | |(rowspan=9) Outreach | |(rowspan=9) Outreach | ||
191 196 || 9-10 | | | ||
192 197 || 10-11 | | | ||
193 198 || 11-12 | | | ||
194   || 12-1 | | | ||
195   || 1-2 | | | ||
196   || 2-3 |(y=3) CSCI 102 | CSCI 101 | CSCI 101 ||
197   || 3-4 | | ||
198   || 4-5 | | ||
  199 || 12-13 | | | ||
  200 || 13-14 | | | ||
  201 || 14-15 |(rowspan=3) CSCI 102 | CSCI 101 | CSCI 101 ||
  202 || 15-16 | | ||
  203 || 16-17 | | ||
199 204 |#
200 205
201 206 Spans are particularly useful to create **subheadings**:
203 208 %%
204 209 #|
205 210 ?| Fruit production in the last two years |?
206   *| |(x=2) Apples |(x=2) Pears |*
207   *| | 2005 | 2006 | 2005 | 2006 |*
  211 *| |(colspan=2) Apples |(colspan=2) Pears |*
  212 *| | 2025 | 2026 | 2025 | 2026 |*
208 213 ^| Mary | 300Kg | 320Kg | 400kg | 280Kg ||
209 214 ^| John | 400Kg | 630Kg | 210Kg | 300Kg ||
210 215 |#
212 217
213 218 #|
214 219 ?| Fruit production in the last two years |?
215   *| |(x=2) Apples |(x=2) Pears |*
216   *| | 2005 | 2006 | 2005 | 2006 |*
  220 *| |(colspan=2) Apples |(colspan=2) Pears |*
  221 *| | 2025 | 2026 | 2025 | 2026 |*
217 222 ^| Mary | 300Kg | 320Kg | 400kg | 280Kg ||
218 223 ^| John | 400Kg | 630Kg | 210Kg | 300Kg ||
219 224 |#
222 227
223 228 %%
224 229 #|
225   ||(x=2;y=2) 2x2 |(x=2) 2x1 |(y=2) 1x2 ||
226   ||(y=2) 1x2 | 1x1 ||
227   || 1x1 | 1x1 |(x=2) 2x1 ||
228   |#
229   %%
230  
231   #|
232   ||(x=2;y=2) 2x2 |(x=2) 2x1 |(y=2) 1x2 ||
233   ||(y=2) 1x2 | 1x1 ||
234   || 1x1 | 1x1 |(x=2) 2x1 ||
235   |#
236  
237  
238   ===Formatting text within tables===
  230 ||(colspan=2 rowspan=2) 2x2 |(colspan=2) 2x1 |(rowspan=2) 1x2 ||
  231 ||(rowspan=2) 1x2 | 1x1 ||
  232 || 1x1 | 1x1 |(colspan=2) 2x1 ||
  233 |#
  234 %%
  235
  236 #|
  237 ||(colspan=2 rowspan=2) 2x2 |(colspan=2) 2x1 |(rowspan=2) 1x2 ||
  238 ||(rowspan=2) 1x2 | 1x1 ||
  239 || 1x1 | 1x1 |(colspan=2) 2x1 ||
  240 |#
  241
  242
  243 ===Formatting text===
239 244
240 245 You can use any kind of basic [[wackowiki:Doc/English/Formatting Wacko markup]] to render text within tables.
241 246 The following example adds basic formatting to cell content:
244 249 #|
245 250 ?| Using text formatting within tables |?
246 251 || ##Monospaced## | //Italics// | **Bold** | __Underlined__ ||
247   || !!Highlighted!! | --Strikethrough-- |(x=2) **//Bold italics//** ||
  252 || !!Highlighted!! | --Strikethrough-- |(colspan=2) **//Bold italics//** ||
248 253 |#
249 254 %%
250 255
251 256 #|
252 257 ?| Using text formatting within tables |?
253 258 || ##Monospaced## | //Italics// | **Bold** | __Underlined__ ||
254   || !!Highlighted!! | --Strikethrough-- |(x=2) **//Bold italics//** ||
255   |#
256  
257   ===Adding actions and images within tables===
  259 || !!Highlighted!! | --Strikethrough-- |(colspan=2) **//Bold italics//** ||
  260 |#
  261
  262 ===Actions and images===
258 263
259 264 Simple, content-generating [[Docs:UsingActions actions]] (including [[Docs:AddingImages images]]) can be added within table cells and headings.
260 265
274 279 || !!some colored text!! ||
275 280 |#
276 281
277   ===Adding links within tables===
  282 ===Links===
278 283
279 284 All the available options to create [[Docs:AddingLinks links]] can be used within table cells or headings:
280 285
283 288 ?| Adding links within tables |?
284 289 || Camelcase links: | SandBox ||
285 290 || Escaped camelcase links: | ~SandBox escaped ||
286   || Forced links: | [[HomePage main]] ||
  291 || Forced links: | [[/HomePage main]] ||
287 292 || Interwiki links: | Wikipedia:Unicode ||
288 293 || Forced interwiki links: | [[Wikipedia:Unicode Unicode article on Wikipedia]] ||
289 294 || External links: | http://www.example.com ||
296 301 ?| Adding links within tables |?
297 302 || Camelcase links: | SandBox ||
298 303 || Escaped camelcase links: | ~SandBox escaped ||
299   || Forced links: | [[HomePage main]] ||
  304 || Forced links: | [[/HomePage main]] ||
300 305 || Interwiki links: | Wikipedia:Unicode ||
301 306 || Forced interwiki links: | [[Wikipedia:Unicode Unicode article on Wikipedia]] ||
302 307 || External links: | http://www.example.com ||
304 309 || Image links: | file:/IMG_20250615_134454_135-min.jpg?600 ||
305 310 |#
306 311
307   ===Adding HTML within tables===
308  
309   You can also use [[Docs:UsingHTML embedded HTML]] in table elements:
  312 ===HTML===
  313
  314 You can also use [[Docs:UsingHTML embedded HTML]] in table elements:
310 315
311 316 %%
312 317 #|
313 318 ?| Embedding HTML within tables |?
314 319 || Here's some superscript: a^^2+1^^ ||
315   || And here's some subscript too: avv2kvv ||
  320 || And here's some subscript too: a,,2k,, ||
316 321 || I love acronyms: (?WYTIWYG What You Think Is What You Get?) ||
317 322 |#
318 323 %%
320 325 #|
321 326 ?| Embedding HTML within tables |?
322 327 || Here's some superscript: a^^2+1^^ ||
323   || And here's some subscript too: avv2kvv ||
  328 || And here's some subscript too: a,,2k,, ||
324 329 || I love acronyms: (?WYTIWYG What You Think Is What You Get?) ||
325 330 |#
326 331
327   ===Adding a touch of style===
  332 ===Styling===
328 333 The table markup introduces a new [[TableMarkupReference style selector]]. CSS style options can be added to any element by enclosing them within **single braces**, right before the element content, e.g.:
329   ##""||""{''style options''}Element content""||""##
  334 ##""||""{''style options''} Element content ""||""##
330 335
331 336 For example, to render a cell with **red background** and **white text color**, you can do the following:
332 337
386 391
387 392 %%
388 393 #|
389   ?|Give priority|?
390   ||(x=2;y=2){background-color:pink}2x2|(x=2){background-color:lightblue}2x1|(y=2){background-color:lightyellow}1x2||
391   ||(y=2){background-color:lightyellow}1x2|{background-color:#333;color:white}1x1||
392   ||{background-color:lightblue}1x1|{background-color:#333;color:white}1x1|(x=2){background-color:pink}2x1||
393   |#
394   %%
395  
396   #|
397   ?|Give priority|?
398   ||(x=2;y=2){background-color:pink}2x2|(x=2){background-color:lightblue}2x1|(y=2){background-color:lightyellow}1x2||
399   ||(y=2){background-color:lightyellow}1x2|{background-color:#333;color:white}1x1||
400   ||{background-color:lightblue}1x1|{background-color:#333;color:white}1x1|(x=2){background-color:pink}2x1||
  394 ?| Give priority |?
  395 ||(colspan=2 rowspan=2 bgcolor=pink) 2x2 |(colspan=2 bgcolor=lightblue) 2x1 |(rowspan=2 bgcolor=lightyellow) 1x2 ||
  396 ||(rowspan=2 bgcolor=lightyellow) 1x2 |(bgcolor=darkslategray) !!(white)1x1!! ||
  397 ||(bgcolor=lightblue) 1x1 |(bgcolor=darkslategray) !!(white)1x1!! |(colspan=2 bgcolor=pink) 2x1 ||
  398 |#
  399 %%
  400
  401 #|
  402 ?| Give priority |?
  403 ||(colspan=2 rowspan=2 bgcolor=pink) 2x2 |(colspan=2 bgcolor=lightblue) 2x1 |(rowspan=2 bgcolor=lightyellow) 1x2 ||
  404 ||(rowspan=2 bgcolor=lightyellow) 1x2 |(bgcolor=darkslategray) !!(white)1x1!! ||
  405 ||(bgcolor=lightblue) 1x1 |(bgcolor=darkslategray) !!(white)1x1!! |(colspan=2 bgcolor=pink) 2x1 ||
401 406 |#
402 407
403 408 ===Adding style through classes===
444 449
445 450 ===Referring to elements: the ##id## attribute===
446 451
447   ##id## attributes are used to refer to unique elements in a page and to provide an anchor for styling and linking. You can specify an ##id## for any table element by using the ##(i:''id'')## parameter.
  452 ##id## attributes are used to refer to unique elements in a page and to provide an anchor for styling and linking. You can specify an ##id## for any table element by using the ##(id=''id'')## parameter.
448 453
449 454 For example, the following markup creates a table with the ##id## "main_table" containing two cells with ##id##'s "cell_1" and "cell_2"
450 455
451 456 %%
  457 #|  
  458 !|(id=main_table)|!  
  459 ?|Using id to refer to table elements|?  
  460 ||(id=cell_1)This cell can be referred to by using the ##cell_1## id||  
  461 ||(id=cell_2)This cell can be referred to by using the ##cell_2## id||  
  462 |#  
  463 %%  
  464  
452 465 #|
453 466 !|(i:main_table)|!
454 467 ?|Using id to refer to table elements|?
455   ||(i:cell_1)This cell can be referred to by using the ##cell_1## id||
456   ||(i:cell_2)This cell can be referred to by using the ##cell_2## id||
457   |#
458   %%
459  
460   #|
461   !|(i:main_table)|!
462   ?|Using id to refer to table elements|?
463   ||(i:cell_1)This cell can be referred to by using the ##cell_1## id||
464   ||(i:cell_2)This cell can be referred to by using the ##cell_2## id||
  468 ||(id=cell_1)This cell can be referred to by using the ##cell_1## id||
  469 ||(id=cell_2)This cell can be referred to by using the ##cell_2## id||
465 470 |#
466 471
467 472 ===Accessibility options===
468    
469   ====Adding titles====  
470    
471   Any table element can be given a ##title## attribute to enhance its accessibility. Titles are typically displayed in graphical browsers by hovering over the corresponding element and are useful to display unobtrusive descriptions about specific elements. You can specify a ##title## for any table element by using the ##(t:''title'')## parameter.  
472    
473   The following example adds titles to several table elements (you can hover over the table to display them):  
474    
475   %%  
476   #|  
477   !|(t:Comparative figures for fruit production in the last year){width: 350px}|!  
478   ?|Fruit production in 2006|?  
479   *| |(t:yearly production of apples)Apples|(t:yearly production of pears)Pears|*  
480   ^|(t:Mary's contribution to 2006 production)Mary|(t:Mary's production of apples in 2006){text-align:center}300Kg|(t:Mary's production of pears in 2006){text-align:center}320Kg||  
481   ^|(t:John's contribution to 2006 production)John|(t:John's production of apples in 2006){text-align:center}400Kg|(t:John's production of pears in 2006){text-align:center}630Kg||  
482   |#  
483   %%  
484    
485   #|  
486   !|(t:Comparative figures for fruit production in the last year){width: 350px}|!  
487   ?|Fruit production in 2006|?  
488   *| |(t:yearly production of apples)Apples|(t:yearly production of pears)Pears|*  
489   ^|(t:Mary's contribution to 2006 production)Mary|(t:Mary's production of apples in 2006){text-align:center}300Kg|(t:Mary's production of pears in 2006){text-align:center}320Kg||  
490   ^|(t:John's contribution to 2006 production)John|(t:John's production of apples in 2006){text-align:center}400Kg|(t:John's production of pears in 2006){text-align:center}630Kg||  
491   |#  
492    
493   ====Adding a summary====  
494    
495   Tables can take an optional ##summary## attribute to describe the purpose and/or structure of the table. The description provided by the summary attribute is particularly helpful to users of non-visual browsers. You can specify a summary by adding a ##(u:''Summary'')## parameter in the table global attributes.  
496    
497   For example, the following line:  
498   ##""!|(u:This is a summary)|!""##  
499   will add to the table a ##summary## attribute with the value ##This is a summary##.  
500 473
501 474 ====Table head, table body and table foot====
502 475
511 484
512 485 %%
513 486 #|
514   !|(u:A table with summary, caption, head, foot and body){width: 400px}|!
  487 !|{width: 400px}|!
515 488 ?|Here's how you can group rows|?
516 489 |[|
517 490 *|Name|Place|Telephone|*
526 499 %%
527 500
528 501 #|
529   !|(u:A table with summary, caption, head, foot and body){width: 400px}|!
  502 !|{width: 400px}|!
530 503 ?|Here's how you can group rows|?
531 504 |[|
532 505 *|Name|Place|Telephone|*
542 515 ====Heading scope====
543 516
544 517 To be semantically correct and accessible to users with non-visual browsers, headings should contain scope attributes describing the cell range they refer to.
545     * Column heading scopes can be specified using the ##(o:col)## parameter in the corresponding column heading;
546     * Row heading scopes can be specified using the ##(o:row)## parameter in the corresponding row heading;
  518   * Column heading scopes can be specified using the ##(scope=col)## parameter in the corresponding column heading;
  519   * Row heading scopes can be specified using the ##(scope=row)## parameter in the corresponding row heading;
547 520
548 521 The following example shows how to correctly add column and row scopes to a table to make it accessible:
549 522
550 523 %%
551 524 #|
552   !|(u:The number of employees and the foundation year of some imaginary companies.)|!  
553 525 ?|Table 1: Company data||
554 526 |[|
555   *| |(o:col)Employees|(o:col)Founded|*
  527 *| |(scope=col)Employees|(scope=col)Founded|*
556 528 |#|
557   ^|(o:row)ACME Inc|1000|1947||
558   ^|(o:row)XYZ Corp|2000|1973||
559   |#
560   %%
561  
562   #|
563   !|(u:The number of employees and the foundation year of some imaginary companies.)|!
  529 ^|(scope=row)ACME Inc|1000|1947||
  530 ^|(scope=row)XYZ Corp|2000|1973||
  531 |#
  532 %%
  533
  534 #|
564 535 ?|Table 1: Company data|?
565 536 |[|
566   *| |(o:col)Employees|(o:col)Founded|*
  537 *| |(scope=col)Employees|(scope=col)Founded|*
567 538 |#|
568   ^|(o:row)ACME Inc|1000|1947||
569   ^|(o:row)XYZ Corp|2000|1973||
570   |#
571  
  539 ^|(scope=row)ACME Inc|1000|1947||
  540 ^|(scope=row)XYZ Corp|2000|1973||
  541 |#
  542