Difference between revisions for Playground / Table Markup Guide
| Version1 | Version2 | Differences |
|---|---|---|
| 1 |
As of |
|
| 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 | 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 ## |
|
| 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 ##""| |
|
| 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 | 126 | *| | Apples | Pears |* |
| 122 | 127 | ^| Mary | 300Kg | 320Kg || |
| 123 | 128 | ^| John | 400Kg | 630Kg || |
| … | … | … |
| 125 | 130 | %% |
| 126 | 131 | |
| 127 | 132 | #| |
| 128 |
?| Fruit production in 20 |
|
| 133 | ?| Fruit production in 2026 |? | |
| 129 | 134 | *| | Apples | Pears |* |
| 130 | 135 | ^| Mary | 300Kg | 320Kg || |
| 131 | 136 | ^| John | 400Kg | 630Kg || |
| … | … | … |
| 173 | 178 | %% |
| 174 | 179 | #| |
| 175 | 180 | *| | Mon | Tue | Wed | Thu | Fri |* |
| 176 |
|| 8-9 | |(y=9) Outreach |
|
| 181 | || 8-9 | |(y=9) Outreach | |(y=9) Outreach | || | |
| 177 | 182 | || 9-10 | | | || <-- reduced by two columns |
| 178 | 183 | || 10-11 | | | || |
| 179 | 184 | || 11-12 | | | || |
| 180 |
|| 12-1 |
|
| 181 |
|| 1 |
|
| 182 |
|| |
|
| 183 |
|| |
|
| 184 |
|| |
|
| 185 | || 12-13 | | | || | |
| 186 | || 13-14 | | | || | |
| 187 | || 14-15 |(y=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 |
|
| 195 | || 8-9 | |(y=9) Outreach | |(y=9) Outreach | || | |
| 191 | 196 | || 9-10 | | | || |
| 192 | 197 | || 10-11 | | | || |
| 193 | 198 | || 11-12 | | | || |
| 194 |
|| 12-1 |
|
| 195 |
|| 1 |
|
| 196 |
|| |
|
| 197 |
|| |
|
| 198 |
|| |
|
| 199 | || 12-13 | | | || | |
| 200 | || 13-14 | | | || | |
| 201 | || 14-15 |(y=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**: |
| … | … | … |
| 204 | 209 | #| |
| 205 | 210 | ?| Fruit production in the last two years |? |
| 206 | 211 | *| |(x=2) Apples |(x=2) Pears |* |
| 207 |
*| | 20 |
|
| 212 | *| | 2025 | 2026 | 2025 | 2026 |* | |
| 208 | 213 | ^| Mary | 300Kg | 320Kg | 400kg | 280Kg || |
| 209 | 214 | ^| John | 400Kg | 630Kg | 210Kg | 300Kg || |
| 210 | 215 | |# |
| … | … | … |
| 213 | 218 | #| |
| 214 | 219 | ?| Fruit production in the last two years |? |
| 215 | 220 | *| |(x=2) Apples |(x=2) Pears |* |
| 216 |
*| | 20 |
|
| 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 |
|
| 230 | ||(x=2 y=2) 2x2 |(x=2) 2x1 |(y=2) 1x2 || | |
| 226 | 231 | ||(y=2) 1x2 | 1x1 || |
| 227 | 232 | || 1x1 | 1x1 |(x=2) 2x1 || |
| 228 | 233 | |# |
| 229 | 234 | %% |
| 230 | 235 | |
| 231 | 236 | #| |
| 232 |
||(x=2 |
|
| 237 | ||(x=2 y=2) 2x2 |(x=2) 2x1 |(y=2) 1x2 || | |
| 233 | 238 | ||(y=2) 1x2 | 1x1 || |
| 234 | 239 | || 1x1 | 1x1 |(x=2) 2x1 || |
| 235 | 240 | |# |
| … | … | … |
| 283 | 288 | ?| Adding links within tables |? |
| 284 | 289 | || Camelcase links: | SandBox || |
| 285 | 290 | || Escaped camelcase links: | ~SandBox escaped || |
| 286 |
|| Forced links: | [[ |
|
| 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 || |
| 290 | 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 | 301 | ?| Adding links within tables |? |
| 297 | 302 | || Camelcase links: | SandBox || |
| 298 | 303 | || Escaped camelcase links: | ~SandBox escaped || |
| 299 |
|| Forced links: | [[ |
|
| 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 || |
| 303 | 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 | 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 | #| |
| … | … | … |
| 386 | 391 | |
| 387 | 392 | %% |
| 388 | 393 | #| |
| 389 |
?| |
|
| 390 |
||(x=2 |
|
| 391 |
||(y=2){background-color:lightyellow} |
|
| 392 |
||{background-color:lightblue} |
|
| 393 |
|# |
|
| 394 |
%% |
|
| 395 |
|
|
| 396 |
#| |
|
| 397 |
?| |
|
| 398 |
||(x=2 |
|
| 399 |
||(y=2){background-color:lightyellow} |
|
| 400 |
||{background-color:lightblue} |
|
| 394 | ?| Give priority |? | |
| 395 | ||(x=2 y=2){background-color:pink} 2x2 |(x=2){background-color:lightblue} 2x1 |(y=2){background-color:lightyellow} 1x2 || | |
| 396 | ||(y=2){background-color:lightyellow} 1x2 |{background-color:#333;color:white} 1x1 || | |
| 397 | ||{background-color:lightblue} 1x1 |{background-color:#333;color:white} 1x1 |(x=2){background-color:pink} 2x1 || | |
| 398 | |# | |
| 399 | %% | |
| 400 | ||
| 401 | #| | |
| 402 | ?| Give priority |? | |
| 403 | ||(x=2 y=2){background-color:pink} 2x2 |(x=2){background-color:lightblue} 2x1 |(y=2){background-color:lightyellow} 1x2 || | |
| 404 | ||(y=2){background-color:lightyellow} 1x2 |{background-color:#333;color:white} 1x1 || | |
| 405 | ||{background-color:lightblue} 1x1 |{background-color:#333;color:white} 1x1 |(x=2){background-color: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 |
|
| 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 | 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 | 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 | ||(i=cell_1)This cell can be referred to by using the ##cell_1## id|| | |
| 469 | ||(i=cell_2)This cell can be referred to by using the ##cell_2## id|| | |
| 465 | 470 | |# |
| 466 | 471 | |
| 467 | 472 | ===Accessibility options=== |
| 468 |
|
|
| 469 |
|
|
| 470 |
|
|
| 471 |
|
|
| 472 |
|
|
| 473 |
|
|
| 474 |
|
|
| 475 |
|
|
| 476 |
|
|
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| 480 |
|
|
| 481 |
|
|
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
|
| 491 |
|
|
| 492 |
|
|
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
|
|
| 497 |
|
|
| 498 |
|
|
| 499 |
|
|
| 500 | 473 | |
| 501 | 474 | ====Table head, table body and table foot==== |
| 502 | 475 | |
| … | … | … |
| 511 | 484 | |
| 512 | 485 | %% |
| 513 | 486 | #| |
| 514 |
!| |
|
| 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 |
!| |
|
| 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 |
|
| 546 |
* Row heading scopes can be specified using the ##(o |
|
| 518 | * Column heading scopes can be specified using the ##(o=col)## parameter in the corresponding column heading; | |
| 519 | * Row heading scopes can be specified using the ##(o=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 |
|
|
| 553 | 525 | ?|Table 1: Company data|| |
| 554 | 526 | |[| |
| 555 |
*| |(o |
|
| 527 | *| |(o=col)Employees|(o=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 | ^|(o=row)ACME Inc|1000|1947|| | |
| 530 | ^|(o=row)XYZ Corp|2000|1973|| | |
| 531 | |# | |
| 532 | %% | |
| 533 | ||
| 534 | #| | |
| 564 | 535 | ?|Table 1: Company data|? |
| 565 | 536 | |[| |
| 566 |
*| |(o |
|
| 537 | *| |(o=col)Employees|(o=col)Founded|* | |
| 567 | 538 | |#| |
| 568 |
^|(o |
|
| 569 |
^|(o |
|
| 570 |
|# |
|
| 571 |
|
|
| 539 | ^|(o=row)ACME Inc|1000|1947|| | |
| 540 | ^|(o=row)XYZ Corp|2000|1973|| | |
| 541 | |# | |
| 542 |