Difference between revisions for Playground / Table Markup Guide
| Version1 | Version2 | ||
|---|---|---|---|
| 1 |
As of ##6.2##, Wacko |
1 | As of ##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 | 2 | ||
| 3 | {{toc numerate=1}} | 3 | {{toc numerate=1}} |
| 4 | 4 | ||
| 5 | ===Table basics: cells, rows, columns=== | 5 | ===Table basics=== |
| 6 | ====Cells==== | ||
| 6 | 7 | ||
| 7 | The most basic element of a table is a **cell**. Single cells can be created using the standard delimiter ##""||""##, e.g.: | 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 | Note that a cell must always be open and closed by delimiters. | 20 | Note that a cell must always be open and closed by delimiters. |
| 20 | 21 | ||
| 22 | ====Rows==== | ||
| 23 | |||
| 21 | **Rows** can be created by adding on the same line multiple cells: | 24 | **Rows** can be created by adding on the same line multiple cells: |
| 22 | 25 | ||
| 23 | %% | 26 | %% |
| … | … | … | … |
| 29 | #| | 32 | #| |
| 30 | || Cell 1 | Cell 2 | Cell 3 || | 33 | || Cell 1 | Cell 2 | Cell 3 || |
| 31 | |# | 34 | |# |
| 35 | |||
| 36 | ====Columns==== | ||
| 32 | 37 | ||
| 33 | **Columns** can be created by adding rows on separate lines: | 38 | **Columns** can be created by adding rows on separate lines: |
| 34 | 39 | ||
| … | … | … | … |
| 63 | |# | 68 | |# |
| 64 | 69 | ||
| 65 | ===Headings=== | 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 ## |
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. |
| 67 |
|
72 | |
| 68 |
The following is an example of a simple table with **column headings** |
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 | || 300Kg | 480Kg || | 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 ##""| |
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 20 |
125 | ?| Fruit production in 2026 |? |
| 121 | *| | Apples | Pears |* | 126 | *| | Apples | Pears |* |
| 122 | ^| Mary | 300Kg | 320Kg || | 127 | ^| Mary | 300Kg | 320Kg || |
| 123 | ^| John | 400Kg | 630Kg || | 128 | ^| John | 400Kg | 630Kg || |
| … | … | … | … |
| 125 | %% | 130 | %% |
| 126 | 131 | ||
| 127 | #| | 132 | #| |
| 128 |
?| Fruit production in 20 |
133 | ?| Fruit production in 2026 |? |
| 129 | *| | Apples | Pears |* | 134 | *| | Apples | Pears |* |
| 130 | ^| Mary | 300Kg | 320Kg || | 135 | ^| Mary | 300Kg | 320Kg || |
| 131 | ^| John | 400Kg | 630Kg || | 136 | ^| John | 400Kg | 630Kg || |
| … | … | … | … |
| 173 | %% | 178 | %% |
| 174 | #| | 179 | #| |
| 175 | *| | Mon | Tue | Wed | Thu | Fri |* | 180 | *| | Mon | Tue | Wed | Thu | Fri |* |
| 176 |
|| 8-9 | |(y=9) Outreach |
181 | || 8-9 | |(y=9) Outreach | |(y=9) Outreach | || |
| 177 | || 9-10 | | | || <-- reduced by two columns | 182 | || 9-10 | | | || <-- reduced by two columns |
| 178 | || 10-11 | | | || | 183 | || 10-11 | | | || |
| 179 | || 11-12 | | | || | 184 | || 11-12 | | | || |
| 180 |
|| 12-1 |
185 | || 12-13 | | | || |
| 181 |
|| 1 |
186 | || 13-14 | | | || |
| 182 |
|| |
187 | || 14-15 |(y=3) CSCI 102 | CSCI 101 | CSCI 101 || |
| 183 |
|| |
188 | || 15-16 | | || <-- reduced by one column |
| 184 |
|| |
189 | || 16-17 | | || |
| 185 | |# | 190 | |# |
| 186 | %% | 191 | %% |
| 187 | 192 | ||
| 188 | #| | 193 | #| |
| 189 | *| | Mon | Tue | Wed | Thu | Fri |* | 194 | *| | Mon | Tue | Wed | Thu | Fri |* |
| 190 |
|| 8-9 | |(y=9) Outreach |
195 | || 8-9 | |(y=9) Outreach | |(y=9) Outreach | || |
| 191 | || 9-10 | | | || | 196 | || 9-10 | | | || |
| 192 | || 10-11 | | | || | 197 | || 10-11 | | | || |
| 193 | || 11-12 | | | || | 198 | || 11-12 | | | || |
| 194 |
|| 12-1 |
199 | || 12-13 | | | || |
| 195 |
|| 1 |
200 | || 13-14 | | | || |
| 196 |
|| |
201 | || 14-15 |(y=3) CSCI 102 | CSCI 101 | CSCI 101 || |
| 197 |
|| |
202 | || 15-16 | | || |
| 198 |
|| |
203 | || 16-17 | | || |
| 199 | |# | 204 | |# |
| 200 | 205 | ||
| 201 | Spans are particularly useful to create **subheadings**: | 206 | Spans are particularly useful to create **subheadings**: |
| … | … | … | … |
| 204 | #| | 209 | #| |
| 205 | ?| Fruit production in the last two years |? | 210 | ?| Fruit production in the last two years |? |
| 206 | *| |(x=2) Apples |(x=2) Pears |* | 211 | *| |(x=2) Apples |(x=2) Pears |* |
| 207 |
*| | 20 |
212 | *| | 2025 | 2026 | 2025 | 2026 |* |
| 208 | ^| Mary | 300Kg | 320Kg | 400kg | 280Kg || | 213 | ^| Mary | 300Kg | 320Kg | 400kg | 280Kg || |
| 209 | ^| John | 400Kg | 630Kg | 210Kg | 300Kg || | 214 | ^| John | 400Kg | 630Kg | 210Kg | 300Kg || |
| 210 | |# | 215 | |# |
| … | … | … | … |
| 213 | #| | 218 | #| |
| 214 | ?| Fruit production in the last two years |? | 219 | ?| Fruit production in the last two years |? |
| 215 | *| |(x=2) Apples |(x=2) Pears |* | 220 | *| |(x=2) Apples |(x=2) Pears |* |
| 216 |
*| | 20 |
221 | *| | 2025 | 2026 | 2025 | 2026 |* |
| 217 | ^| Mary | 300Kg | 320Kg | 400kg | 280Kg || | 222 | ^| Mary | 300Kg | 320Kg | 400kg | 280Kg || |
| 218 | ^| John | 400Kg | 630Kg | 210Kg | 300Kg || | 223 | ^| John | 400Kg | 630Kg | 210Kg | 300Kg || |
| 219 | |# | 224 | |# |
| … | … | … | … |
| 283 | ?| Adding links within tables |? | 288 | ?| Adding links within tables |? |
| 284 | || Camelcase links: | SandBox || | 289 | || Camelcase links: | SandBox || |
| 285 | || Escaped camelcase links: | ~SandBox escaped || | 290 | || Escaped camelcase links: | ~SandBox escaped || |
| 286 |
|| Forced links: | [[ |
291 | || Forced links: | [[/HomePage main]] || |
| 287 | || Interwiki links: | Wikipedia:Unicode || | 292 | || Interwiki links: | Wikipedia:Unicode || |
| 288 | || Forced interwiki links: | [[Wikipedia:Unicode Unicode article on Wikipedia]] || | 293 | || Forced interwiki links: | [[Wikipedia:Unicode Unicode article on Wikipedia]] || |
| 289 | || External links: | http://www.example.com || | 294 | || External links: | http://www.example.com || |
| 290 | || Forced external links: | [[http://www.example.com Example.com]] || | 295 | || Forced external links: | [[http://www.example.com Example.com]] || |
| 291 |
|| Image links: | file:/ |
296 | || Image links: | file:/Przewalski-horses.jpg?600 || |
| 292 | |# | 297 | |# |
| 293 | %% | 298 | %% |
| 294 | 299 | ||
| … | … | … | … |
| 296 | ?| Adding links within tables |? | 301 | ?| Adding links within tables |? |
| 297 | || Camelcase links: | SandBox || | 302 | || Camelcase links: | SandBox || |
| 298 | || Escaped camelcase links: | ~SandBox escaped || | 303 | || Escaped camelcase links: | ~SandBox escaped || |
| 299 |
|| Forced links: | [[ |
304 | || Forced links: | [[/HomePage main]] || |
| 300 | || Interwiki links: | Wikipedia:Unicode || | 305 | || Interwiki links: | Wikipedia:Unicode || |
| 301 | || Forced interwiki links: | [[Wikipedia:Unicode Unicode article on Wikipedia]] || | 306 | || Forced interwiki links: | [[Wikipedia:Unicode Unicode article on Wikipedia]] || |
| 302 | || External links: | http://www.example.com || | 307 | || External links: | http://www.example.com || |
| 303 | || Forced external links: | [[http://www.example.com Example.com]] || | 308 | || Forced external links: | [[http://www.example.com Example.com]] || |
| 304 |
|| Image links: | file:/ |
309 | || Image links: | file:/Przewalski-horses.jpg?600 || |
| 305 | |# | 310 | |# |
| 306 | 311 | ||
| 307 | ===Adding HTML within tables=== | 312 | ===Adding HTML within tables=== |
| 308 | 313 | ||
| 309 |
You can also use [[Docs:UsingHTML embedded HTML]] in table elements: |
314 | You can also use [[Docs:UsingHTML embedded HTML]] in table elements: |
| 310 | 315 | ||
| 311 | %% | 316 | %% |
| 312 | #| | 317 | #| |
| … | … | … | … |
| 444 | 449 | ||
| 445 | ===Referring to elements: the ##id## attribute=== | 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 |
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 ##(i=''id'')## parameter. |
| 448 | 453 | ||
| 449 | For example, the following markup creates a table with the ##id## "main_table" containing two cells with ##id##'s "cell_1" and "cell_2" | 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 | !|(i=main_table)|! | ||
| 459 | ?|Using id to refer to table elements|? | ||
| 460 | ||(i=cell_1)This cell can be referred to by using the ##cell_1## id|| | ||
| 461 | ||(i=cell_2)This cell can be referred to by using the ##cell_2## id|| | ||
| 462 | |# | ||
| 463 | %% | ||
| 464 | |||
| 452 | #| | 465 | #| |
| 453 | !|(i:main_table)|! | 466 | !|(i:main_table)|! |
| 454 | ?|Using id to refer to table elements|? | 467 | ?|Using id to refer to table elements|? |
| 455 | ||(i:cell_1)This cell can be referred to by using the ##cell_1## id|| | 468 | ||(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|| | 469 | ||(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|| | ||
| 465 | |# | 470 | |# |
| 466 | 471 | ||
| 467 | ===Accessibility options=== | 472 | ===Accessibility options=== |
| 468 | 473 | ||
| 469 | ====Adding titles==== | 474 | ====Adding titles==== |
| 470 |
|
475 | |
| 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 |
476 | 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 | 477 | ||
| 473 | The following example adds titles to several table elements (you can hover over the table to display them): | 478 | The following example adds titles to several table elements (you can hover over the table to display them): |
| 474 | 479 | ||
| 475 | %% | 480 | %% |
| 476 | #| | 481 | #| |
| 477 | !|(t:Comparative figures for fruit production in the last year){width: 350px}|! | 482 | !|(t="Comparative figures for fruit production in the last year"){width: 350px}|! |
| 478 | ?|Fruit production in 2006|? | 483 | ?|Fruit production in 2026|? |
| 479 | *| |(t:yearly production of apples)Apples|(t:yearly production of pears)Pears|* | 484 | *| |(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|| | 485 | ^|(t="Mary's contribution to 2026 production")Mary|(t="Mary's production of apples in 2026"){text-align:center}300Kg|(t="Mary's production of pears in 2026"){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|| | 486 | ^|(t="John's contribution to 2026 production")John|(t="John's production of apples in 2026"){text-align:center}400Kg|(t="John's production of pears in 2026"){text-align:center}630Kg|| |
| 482 | |# | 487 | |# |
| 483 | %% | 488 | %% |
| 484 | 489 | ||
| 485 | #| | 490 | #| |
| 486 | !|(t:Comparative figures for fruit production in the last year){width: 350px}|! | 491 | !|(t="Comparative figures for fruit production in the last year"){width: 350px}|! |
| 487 | ?|Fruit production in 2006|? | 492 | ?|Fruit production in 2026|? |
| 488 | *| |(t:yearly production of apples)Apples|(t:yearly production of pears)Pears|* | 493 | *| |(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|| | 494 | ^|(t="Mary's contribution to 2026 production")Mary|(t="Mary's production of apples in 2026"){text-align:center}300Kg|(t="Mary's production of pears in 2026"){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|| | 495 | ^|(t="John's contribution to 2026 production")John|(t="John's production of apples in 2026"){text-align:center}400Kg|(t="John's production of pears in 2026"){text-align:center}630Kg|| |
| 491 | |# | 496 | |# |
| 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 | 497 | ||
| 501 | ====Table head, table body and table foot==== | 498 | ====Table head, table body and table foot==== |
| 502 | 499 | ||
| … | … | … | … |
| 511 | 508 | ||
| 512 | %% | 509 | %% |
| 513 | #| | 510 | #| |
| 514 |
!| |
511 | !|{width: 400px}|! |
| 515 | ?|Here's how you can group rows|? | 512 | ?|Here's how you can group rows|? |
| 516 | |[| | 513 | |[| |
| 517 | *|Name|Place|Telephone|* | 514 | *|Name|Place|Telephone|* |
| … | … | … | … |
| 526 | %% | 523 | %% |
| 527 | 524 | ||
| 528 | #| | 525 | #| |
| 529 |
!| |
526 | !|{width: 400px}|! |
| 530 | ?|Here's how you can group rows|? | 527 | ?|Here's how you can group rows|? |
| 531 | |[| | 528 | |[| |
| 532 | *|Name|Place|Telephone|* | 529 | *|Name|Place|Telephone|* |
| … | … | … | … |
| 542 | ====Heading scope==== | 539 | ====Heading scope==== |
| 543 | 540 | ||
| 544 | To be semantically correct and accessible to users with non-visual browsers, headings should contain scope attributes describing the cell range they refer to. | 541 | 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 |
542 | * 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 |
543 | * Row heading scopes can be specified using the ##(o=row)## parameter in the corresponding row heading; |
| 547 | 544 | ||
| 548 | The following example shows how to correctly add column and row scopes to a table to make it accessible: | 545 | The following example shows how to correctly add column and row scopes to a table to make it accessible: |
| 549 | 546 | ||
| … | … | … | … |
| 552 | !|(u:The number of employees and the foundation year of some imaginary companies.)|! | 549 | !|(u:The number of employees and the foundation year of some imaginary companies.)|! |
| 553 | ?|Table 1: Company data|| | 550 | ?|Table 1: Company data|| |
| 554 | |[| | 551 | |[| |
| 555 |
*| |(o |
552 | *| |(o=col)Employees|(o=col)Founded|* |
| 556 | |#| | 553 | |#| |
| 557 |
^|(o |
554 | ^|(o=row)ACME Inc|1000|1947|| |
| 558 |
^|(o |
555 | ^|(o=row)XYZ Corp|2000|1973|| |
| 559 | |# | 556 | |# |
| 560 | %% | 557 | %% |
| 561 | 558 | ||
| … | … | … | … |
| 563 | !|(u:The number of employees and the foundation year of some imaginary companies.)|! | 560 | !|(u:The number of employees and the foundation year of some imaginary companies.)|! |
| 564 | ?|Table 1: Company data|? | 561 | ?|Table 1: Company data|? |
| 565 | |[| | 562 | |[| |
| 566 |
*| |(o |
563 | *| |(o=col)Employees|(o=col)Founded|* |
| 567 | |#| | 564 | |#| |
| 568 |
^|(o |
565 | ^|(o=row)ACME Inc|1000|1947|| |
| 569 |
^|(o |
566 | ^|(o=row)XYZ Corp|2000|1973|| |
| 570 |
|# |
567 | |# |
| 571 |
|
568 | |