Summary:Markup to add a rowspan attribute on a
simple table cell
Version:2008-08-29
Prerequisites:None
Status:Just out of beta
Questions answered by this recipe
This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.
- How do I specify that a cell spans 2 or more rows in a simple table?
- How do I lay out a simple table so that a later editor can see the scope of a rowspan?
- How do I lay out a simple table so that a later editor can see the scope of a colspan?
Description
Extend simple table markup to support a rowspan.
The markup ||cell text+++ || adds rowspan="3" to the cell. The number of plus signs (+) defines the number of rows spanned. There must be 2 or more plus signs.
The markup ||____|| has the same effect as the markup ||||, 2 or more underscores (_) are required.
The markup ||^^^^|| has the same effect as the markup ||, 2 or more circumflex accents (^) are required.
That's all. It just works.
Notes
Simple tables can be hard to read. The recipe provides 2 simple table markup options with the sole purpose of making the table easier to edit. They have no effect whatsoever on the output. Their usage is entirely optional. Adding or removing them will not change the output.
Make rowspan more visible
|| border=1
||Spanning rows++ ||Regular text ||
||^^^^^^^^^^^^^^^^^||More text ||
||Plain old text ||Text ends ||
||Spanning rows ||Without using visibility markup ++||
||First column ||
|
| Spanning rows | Regular text |
| More text |
| Plain old text | Text ends |
| Spanning rows | Without using visibility markup |
| First column |
|
Make colspan more visible
|| border=1
||Spanning columns ||_____________||Regular text ||
||More Regular ||More text ||Still more ||
||Spanning columns ||||Without using visibility markup ||
||____________________||Is this meaningful in the first column? ||No||It's
not ||
|| Combine both markups to span three rows (''text centered'')
||____________||||
|
| Spanning columns | Regular text |
| More Regular | More text | Still more |
| Spanning columns | Without using visibility markup |
| Is this meaningful in the first column? | No | It's not |
| Combine both markups to span three rows (text centered) |
|
Spanning rows and columns
|| border=1
||Spanning 3 rows and 2 columns+++ ||||Regular text in third and fourth
columns||||
||^^^^^^^^^^^^^^^^||Second row ||Fourth column ||
||Third row ||Fourth column ||
||Spanning rows and columns++ ||||||Fourth column ||
||Without using visibility markup ||
|
| Spanning 3 rows and 2 columns | Regular text in third and fourth columns |
| Second row | Fourth column |
| Third row | Fourth column |
| Spanning rows and columns | Fourth column |
| Without using visibility markup |
|
Release Notes
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".
See Also
Contributors
jr with help from many others (Christian, Luigi, Peter, Pm, Simon at least).
Comments
Why doesn't this work
overlapping double rows, two columns
||Double row A ++||Column 2 ||
||_____________||Double row B ++||
||Column 1 ||^^^^^^^^^^^^^||
|
| Double row A | Column 2 |
| Double row B |
| Column 1 |
|
but this does?
overlapping double rows, three columns
||Double row ++||Column 2||Row one ||
||_____________||Double row ++||Row 2||
||Column 1 ||^^^^^^^^^^^^^||Row 3||
|
| Double row | Column 2 | Row one |
| Double row | Row 2 |
| Column 1 | Row 3 |
|
It does what the markup specifies. Here is the HTML the first example produces, which looks exactly right:
<tr class='row1 ind1'><td rowspan="2">Double row </td><td >Column 2</td></tr>
<tr class='row2 ind2'><td rowspan="2">Double row </td></tr>
<tr class='row3 ind3'><td align='left'>Column 1</td></tr>
The colspan in the first column, as specified by the ||_________|| markup, is correctly ignored. It seems to be up to the browser how it interprets the HTML.