Help talk:Table#Scrolling tables and sticky headers
{{skip to TOC}}
{{talk header|search=yes}}
{{WikiProject banner shell|
{{WikiProject Help|importance=mid}}
}}
{{Contentious topics/talk notice|topic=mos}}
{{annual readership}}
{{Split article|from=Help:Table|to=Help:Tables and locations|date=9 December 2023|from_oldid=1189023861}}
{{User:MiszaBot/config
| maxarchivesize = 150K
| counter = 10
| algo = old(180d)
| archive = Help talk:Table/Archive %(counter)d
| archiveheader = {{automatic archive navigator}}
| minthreadstoarchive = 1
| minthreadsleft = 4
}}
Note: You can also ask questions here: Help desk. Teahouse. Village pump (technical).
Not jumping in order
{{re|Rafael Ronen}} Answered at this forum thread: Help talk:Sortable tables#Not jumping in order. --Timeshifter (talk) 18:52, 17 January 2025 (UTC)
Re-org without rewrite
This help page has a lot of useful information, but after years of slow, organic accretion and lack of attention to the overall structure, it has become bloated and somewhat incoherent, with content about related subtopics spread all over the place. I am doing a re-org without rewriting much of anything (except brief portions for clarity), mostly just putting like stuff with like, and renaming existing section headers to better represent what they are really about, and occasionally adding new section headers for better organization clarity.
For example: formerly, we had almost nothing about row operations, except for the brief, desultory section in § Row operations (rev. 1271174926). There was already a fair amount about rows on the page, you just couldn't find it; or if you did, it was not near other stuff about rows, so all very haphazard. Now, section {{alink|Row operations}} has six subsections, almost all of it just by juggling things around. In a couple of cases, subsections were added there by duplicating text already in the (horribly bloated) {{alink|Pipe syntax tutorial}} section, but that redundancy is temporary, and will get de-duped or trimmed after the basic re-org to rationalize the page is mostly completed. Thanks, Mathglot (talk) 23:14, 24 January 2025 (UTC)
: Note that former section 'History of pipe syntax development' was entirely out of place on the Help page, and has been moved to Help:Table/History of pipe syntax development for now, until we figure out what to do with it. Mathglot (talk) 23:24, 24 January 2025 (UTC)
:: I* should add that currently the subpage is not linked from the Help page. Should it be? I don't see a pressing need for it, but I wouldn't object if someone sees value in linking it. Mathglot (talk) 06:27, 30 January 2025 (UTC)
:::{{re|Mathglot}} I think the subpage you created (Help:Table/History of pipe syntax development) should be linked from the Help:Table page. You can decide where since you have been working on all this stuff. --Timeshifter (talk) 04:38, 5 February 2025 (UTC)
:::: {{re|Timeshifter}}, I added a {{tl|For}} section top hatnote to section {{alink|Wikicode syntax tutorial}}, which seems like the logical place for it, as well as a link in the section intro. We could add another one to the {{alink|See also}} appendix, if needed. Mathglot (talk) 08:34, 5 February 2025 (UTC)
:::::{{re|Mathglot}} Good choices. I don't think it needs to be in {{alink|See also}}. --Timeshifter (talk) 17:33, 5 February 2025 (UTC)
Done with re-org for now. Hardly anything new was added, with the exception of a brief intro sentence to a few sections that didn't have one, and one new subsection: {{alink|Link directly to a row}}, which is covered (barely) on some other page, but needs a brief explanation here. The major piece left untackled is the {{alink|Colors in tables}} section, which, like other sections before it, is rather bloated and covers a bunch of different scopes; that is still t.b.d.; also, section {{alink|Wikicode syntax tutorial}} still has a lot of bloat and needs work. But this looks a lot cleaner now, and is easier to navigate to content that was always there before, but buried. Mathglot (talk) 01:39, 25 January 2025 (UTC)
:Thanks for all the work. I moved the "Colors in tables" section to Help:Table/Advanced. There is more room there. --Timeshifter (talk) 18:35, 31 January 2025 (UTC)
'Scope' section needs a rewrite
The {{alink|Scope}} subsection of section {{alink|Wikicode syntax tutorial}} probably needs a rewrite. The problems include misleading claims, a mix of row and column explanations, and poorly done examples. For example, this is the first sentence of {{alink|Scope}}:
: {{talk quote|1=Column headers are identified by ! scope="col" {{!}}
instead of {{!}}
.}}
Most people think of column headers as the descriptive label sitting in a row above the first data row, and may be highlighted by bold font and shaded background, or other highlight style. By that definition, this first sentence is inaccurate, because column headers can be as simple as this:
class=wikitable
|+ Table caption ! Last !! First !! Street | ||
Doe | John | Main |
class=wikitable
|+ Table caption ! Last !! First !! Street | ||
Doe | John | Main |
: which only requires exclamation points, and no scope attributes at all. If we do say anything about scope at all (as opposed to moving it to the Advanced table help, where imho it more properly belongs), then we should not confuse the reader by implying that they need to use it to create column headers, because that is not true, it is much simpler than that.
: I think what we need to say, if we keep the section, is something about how scope attributes may be used to define style for all cells in a column, typically one of the width elements, but could be colors, weight, alignment, and so on.
: Imho, all the stuff about "colgroup" and "rowgroup" should be left out, possibly replaced with a link to the advanced table page. (It's also probably a good place for a "Tip"—possibly in an explanatory note—that even for hardcore wikitext editors, complex tables is one of the few areas where Visual Editor really shines, and is just plain superior to the wikicode editor. Building complex table arrangements with multiple colspan and rowspans are just way easier in VE, and maybe we could also add a quick how-to showing the wikicode user how to switch from wikicode editing to VE while in the middle of an edit, and back again after they finished adjusting the table.)
: I don't have time for any of this just now unfortunately, but I hope to get back to it eventually; or maybe someone will pick this up and run with it. If someone wants to move the whole scope subsection out of this page and into Help:Advanced table formatting (which says nothing about scope !!) with a link from here explaining briefly what it's about, you've got my support. Mathglot (talk) 08:05, 30 January 2025 (UTC)
::The scope section could be moved to either of the advanced pages:
::Help:Advanced table formatting
::I don't have the time or interest for editing that topic.
::--Timeshifter (talk) 16:26, 30 January 2025 (UTC)
::: I decided to look into those two, and started with Help:Advanced table formatting, and was pretty discouraged by its quality. I think it needs a lot of work, correcting errors, and pulling out misleading, or unnecessarily complex solutions or explanations of solutions. I did start to look at that one, but got no further than section "Tiny tables within a text line", which is a complex solution involving nested tables to produce a bordered word embedded in a line of text, which is simple enough to do with inline style without requiring two tables to do it. I blanked the section as not helpful. But that also cured me of any desire to move the scope section there. I haven't looked at Help:Table/Advanced; maybe another time. Mathglot (talk) 07:30, 5 February 2025 (UTC)
Bug regarding colspan and rowspan
I will explain the bug with rowspan:
Below is a table coded to be 4 rows, where "Col B-Rows 3,4" should be shown as 2 rows. However, the third row isn't appearing. I have two tables here, the first to show what the current code outputs, and the second to show what table should like, albeit with an extra column.
class="wikitable sortable plainrowheaders" style="text-align:center;"
|+Table as intended to be shown | rowspan="3" |Col A - Rows 1,2,3 |Col B - Row 1 |
Col B - Row 2 |
rowspan="2" |Col B - Rows 3,4 |
Col A - Row 4 |
class="wikitable sortable plainrowheaders" style="text-align:center;"
|+Table with extra column to show the actual formatting | rowspan="3" |Col A - Rows 1,2,3 |Col B - Row 1 |Col C - Row 1 |
Col B - Row 2
|Col C - Row 2 |
rowspan="2" |Col B - Rows 3,4
|Col C - Row 3 |
Col A - Row 4
|Col C - Row 4 |
Here is the same bug occurring but with colspan:
class="wikitable sortable plainrowheaders" style="text-align:center;"
|+Table as intended to be shown |Col A - Row 1 | colspan="3" |Col B,C,D - Row 1 |
colspan="2" |Col A,B - Row 2
|Col C - Row 2 |Col D - Row 2 |
class="wikitable sortable plainrowheaders" style="text-align:center;"
|+Table with extra row to show the actual formatting |Col A - Row 1 | colspan="3" |Col B,C,D - Row 1 |
colspan="2" |Col A,B - Row 2
|Col C - Row 2 |Col D - Row 2 |
Col A - Row 3
|Col B - Row 3 |Col C - Row 3 |Col D - Row 3 |
I don't know the coding behind "rowspan" and "colspan", but what I do know is that there is an error in its visual output that is causing a row or column to disappear. Spesh531(talk, contrib., ext.) 06:00, 4 February 2025 (UTC)
:{{re|Spesh531}} colspan and rowspan make my brain hurt. Someone else will have to help with this one. You could also ask at WP:VPT. They might also be able to see if there are any related bug reports at Phabricator. --Timeshifter (talk) 14:30, 4 February 2025 (UTC)
::It's not a Wikipedia problem, but how browsers have behaved for decades. Cells are, generally speaking, no larger than they need to be for their contents. In your first example, the bottom border of A1 has no need to be any lower than the bottom border of B3, so they're drawn in line. But there is a very slight displacement, too small to be visible, which may be revealed by adding the border-collapse:separate
declaration:
::
class="wikitable sortable plainrowheaders" style="text-align:center; border-collapse:separate;"
|+Table as intended to be shown | rowspan="3" |Col A - Rows 1,2,3 |Col B - Row 1 |
Col B - Row 2 |
rowspan="2" |Col B - Rows 3,4 |
Col A - Row 4 |
::Going back to the original example, if you add more content to A1 and B3, and constrain the width to force wrapping, you'll see these borders move apart in a more obvious manner:
::
class="wikitable sortable plainrowheaders" style="text-align:center; width:240px;"
|+Table as intended to be shown | rowspan="3" |Col A - Rows 1,2,3 with lots and lots of content. |Col B - Row 1 |
Col B - Row 2 |
rowspan="2" |Col B - Rows 3,4 with lots and lots of content. |
Col A - Row 4 |
::It's because of issues like these that I wrote {{oldid|Template:Rail line three to two|440462152|the original version}} of Template:Rail line three to two to use two columns of six cells, none having rowspan. I subsequently {{diff|Template:Rail line three to two|next|440462152|suppressed the intermediate borders}} to make six cells take on the appearance of a single cell with rowspan=6
. --Redrose64 🌹 (talk) 20:33, 4 February 2025 (UTC)
:::{{re|Redrose64}} Thanks. Concerning the templates in this category and its parent categories:
::::Category:Rail transport succession templates
:::Maybe you can put some of those templates in this category too:
:::Feel free to introduce some of the above templates from any of those categories in the table help pages. And maybe in a new page:
:::Help:Table templates - or similar name.
:::--Timeshifter (talk) 23:48, 4 February 2025 (UTC)
:::I think I have Excel on my mind when it comes to these tables. 😅
:::It's a shame the (sortable) table I'm trying to create only has a single name/term for each box, because the "lots of content" would be great otherwise! In lieu of that, I'm adding "
:::This is the exact part of the table I've built here, showing the wikitext-formatting. (The context here is that Bill Watkins was manager when the Cowboys played at both Association Park and Exposition Park). The only problem is that once the data is sorted, the "Association Park" boxes are now taller than everything else, but it's the only thing I can think of at the moment.
:::
class="wikitable sortable plainrowheaders" style="text-align:center;"
!Team !City !Stadium !Capacity !Manager |
rowspan="4" |Kansas City Cowboys
| rowspan="4" |Kansas City, Missouri | rowspan="3" data-sort-value="Association Park" | " " | rowspan="3" |Unknown |{{sortname|Dave|Rowe|dab=baseball}} |
{{sortname|Sam|Barkley}} |
rowspan="2" |{{sortname|Bill|Watkins|dab=baseball}} |
Exposition Park*
|4,000* |
:::Spesh531(talk, contrib., ext.) 13:55, 5 February 2025 (UTC)
: {{u|Spesh531}}, there is no bug in rowspan and colspan, but it is complex to use, and hard to get right. But here is the code to do the table you want:
class="wikitable"
|+ | rowspan="3" |Col A - Rows 1,2,3 |Col B - Row 1 |Col C - Row 1 |
Col B - Row 2
|Col C - Row 2 |
rowspan="2" |Col B - Rows 3,4
|Col C - Row 3 |
Col A - Row 4
|Col C - Row 4 |
class="wikitable"
|+ | rowspan="3" |Col A - Rows 1,2,3 |Col B - Row 1 |Col C - Row 1 |
Col B - Row 2
|Col C - Row 2 |
rowspan="2" |Col B - Rows 3,4
|Col C - Row 3 |
Col A - Row 4
|Col C - Row 4 |
{{clear}}
: As I indicated somewhere else, this is one area where Visual Editor really shines. Basically, I dislike and do not use VE at all, with this exception: it is great at building tables, and takes the guesswork out of complex rowspan and colspan. If you are a confirmed wikitext user as I am, take the time to learn just enough VE to insert a table, and fiddle with columns and rows. Once you have the basic table structure the way you want, switch back to wikitext for cell data and styling. Good luck! P.S.. creating the table took me about a minute in VE, and worked on first attempt, no retries. Building the side-by-side presentation of it above took longer. Mathglot (talk) 06:26, 5 February 2025 (UTC)
::Much appreciated! Though the table I'm looking for only includes Columns A & B! Col C was there just to show the spacing I was looking for. (I'm probably the same way; more of a wikitext editor than visual) Spesh531(talk, contrib., ext.) 13:41, 5 February 2025 (UTC)
+---------+-------------+--------+
| Row 1 | Row 1 | Row 1 |
+---------+-------------+--------+
| Row 2 | Row 2 | Row 2 |
+---------+-------------+--------+
| Row 3 | | Row 3 |
| | Merged cell | |
+---------+ row 3 and 4 +--------+
| Row 4 | | Row 4 |
+---------+-------------+--------+
::: User:Spesh531, sorry, guess I didn't understand what you wanted. It's hard to describe a complex table with row- or column-spanning cells. If you would like, draw your table in your reply using Ascii art embedded in <pre>...</pre>
, and I can generate the table for you. But you should really try it yourself; start by enabling the visual editor, if it isn't already, in your Preferences > Editing (check the box Enable the visual editor), and follow the tips at Help:Introduction to tables with VisualEditor/2. It's pretty intuitive, but if you get stuck lmk if you need assistance. Mathglot (talk) 20:44, 5 February 2025 (UTC)
Nested divs
{{u|Timeshifter}}, I think my change to collapse nested divs into one div with both class and style (which is definitely a legal construct) had undesirable knock-on effects in some of the table examples, which is why I self-reverted, with a mind to look at it again down the road. I notice you undid my revert, reestablishing my original change, but I think it causes problems: have a look at section {{alink|Float table left or right}} – I think the examples are very broken now; compare that with rev. 1274480787 of 15:51, 7 February 2025. Probably you should self-revert as well; at this point that would mean rolling it back to rev. 1274480787. I can see that you have made three other changes since then (diff), but those could easily be reinstated after a rollback. Mathglot (talk) 21:36, 7 February 2025 (UTC)
:{{re|Mathglot}} I am working on {{alink|Float table left or right}} now. In a sandbox too. Almost done.
:Everything else is fine. --Timeshifter (talk) 22:24, 7 February 2025 (UTC)
:: {{u|Timeshifter}}, Glad to hear it; carry on! Mathglot (talk) 22:29, 7 February 2025 (UTC)
:::{{re|Mathglot}} There is no preview problem in my sandboxes. The preview problem was really messing me up.
:::I see what you are saying about the need to temporarily paste this into the Help:Table section I am editing:
:::
:::{{alink|Float table left or right}} is much better now.
:::--Timeshifter (talk) 23:11, 7 February 2025 (UTC)
Laugh of the day: Pros and cons
I had to laugh, when I looked over at Help:Table/Advanced, and read the part you linked to that just got moved over to Help:Table/Advanced#Other table syntax (diff), including the part that lists the pros and cons of HTML tables versus wikicode syntax. In the row labeled "Pros" for the cell in the Wiki-pipe column (who named it that?) it lists "{{xt|easy to read}}", and "{{xt|easy to write}}"; I nearly had coffee coming out of my nose.
I searched back in Help:Table to see when that was first added, and it goes all the way back to the first version of Help:Table in revision 12094880 of 19:00, 20 September 2004 by {{user|Wilz}}. Seriously made me want to add a laughing man gif or something, right after that part. Yah, it's so easy to read and write, that we only have twenty-six Help and style pages with intricate explanations of features and styles explaining how to do it, including how to have your pipe, and smoke it, too! Lol! But twenty years on and some 2500 edits by 600+ editors later explaining how easy it is, maybe it's time to change that. (On a more serious note, I've been thinking about a way to vastly reduce the size and number of help pages, but it's more of a long-term thing and not something that affects anything we are doing; I have to mull about it for "a while".)
Oh, I forgot to mention the funniest part: if you edit the § Overview section in that revision and look at that table—yep, you guessed it: it's coded in HTML. Guess it was too complex for "wiki-pipe syntax". Hope you enjoyed the chuckle. Mathglot (talk) 02:54, 9 February 2025 (UTC)
Header cell translation
For translation, tables with identical header cells could be translated once and used several times in the ddme article.
For example, in List of Dongfeng vehicles, there are several tables with the same headers (structure).
One could use :
In the Voyah table,
for the First header could stablish that:
Image, in the Spanish version is "Imagen"
For the second, Name(s) is "Nombre(s)" and so on for the full header structure of tehe table.
So, the second time this table structure is used for the M-Hero table, Imagen is automatically translated to Imagen (in the Spanish Wikipedia), Names to Nombres an so on.
This spares a lot of writer effort. 158.172.131.78 (talk) 21:41, 23 February 2025 (UTC)
Need help
Can someone correct the first table at 2025 Greenlandic general election? Can't figure out how to fix it. Thanks. Semsûrî (talk) 17:25, 2 March 2025 (UTC)
:{{replyto|Semsûrî}} There were too many rowspan=
and colspan=
attributes. The fix is to remove them all, and then add in only those that are necessary; which turned out to be just one - the one for the "Party" column heading. --Redrose64 🌹 (talk) 20:27, 2 March 2025 (UTC)
Rates per million. Change to rates per 100,000
The rates in the US tables are per 100,000. So I want to convert the rates in the Europe table below from "per million" to "per 100,000". That means moving the decimal place one place to the left. Can someone do this for me?
Better yet can someone explain exactly how to do it step by step in Libreoffice Calc. I will put this info in a section in Help:Table/Advanced or another table help page.
{{sticky table start}}{{mw-datatable}}{{static row numbers}}
class="wikitable sortable sticky-table-col1 sticky-table-head mw-datatable static-row-numbers" style=text-align:right;
|+ Drug-induced mortality rates per million among adults (15-64), females, males and total.{{cite web |title=Overdose situation (FAQ drug overdose deaths in Europe) |url=https://www.euda.europa.eu/publications/topic-overviews/drug-induced-deaths-faq/overdose-situation_en#faq24-drd-question-8 |website=European Union Drugs Agency}} Scroll down to Figure 1.5. Then; "Show data table". !Location !Year !Females !Males !Total |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Austria}}
|2022 |18 |65 |42 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Belgium}}
|2020 |7 |34 |21 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Bulgaria}}
|2022 |1 |8 |4 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Croatia}}
|2022 |13 |71 |42 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Cyprus}}
|2022 |3 |13 |8 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Czechia}}
|2022 |6 |12 |9 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Denmark}}
|2021 |19 |60 |40 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Estonia}}
|2022 |34 |155 |95 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Finland}}
|2022 |33 |106 |70 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|France}}
|2016 |3 |16 |9 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Germany}}
|2022 |10 |49 |30 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Greece}}
|2020 |10 |58 |34 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Hungary}}
|2021 |3 |9 |6 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Ireland}}
|2020 |64 |130 |97 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Italy}}
|2022 |2 |13 |8 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Latvia}}
|2022 |12 |96 |53 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Lithuania}}
|2022 |10 |86 |47 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Luxembourg}}
|2022 |5 |31 |18 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Malta}}
|2020 |6 |43 |26 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Netherlands}}
|2022 |13 |40 |26 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Norway}}
|2022 |53 |118 |86 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Poland}}
|2021 |5 |11 |8 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Portugal}}
|2021 |4 |19 |11 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Romania}}
|2022 |1 |3 |2 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Slovakia}}
|2021 |3 |12 |7 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Slovenia}}
|2022 |16 |74 |46 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Spain}}
|2021 |7 |34 |21 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Sweden}}
|2022 |35 |102 |70 |
{{flagg|uspeft|pref=Healthcare in|pref2=Health in|Türkiye}}
|2022 |1 |7 |4 |
{{sticky table end}}
{{talk refs}}
--Timeshifter (talk) 14:57, 6 March 2025 (UTC)
:I figured out how to do it in free Google Sheets, freeware LibreOffice Calc, and free Excel online.
:See: User:Timeshifter/Sandbox284.
:--Timeshifter (talk) 22:11, 10 March 2025 (UTC)
::Simplified instructions are here:
::Help:Creating tables#Rates per million or per 100,000.
::--Timeshifter (talk) 00:56, 13 March 2025 (UTC)
Template:Scrolling table doc
See the rarely used templates listed in this doc:
There are better methods here:
I am leaving a note here in hopes some others will look and see if I am correct.
If so, someone with more time than me might put the templates up for deletion here:
I suggested the same here:
--Timeshifter (talk) 11:45, 8 April 2025 (UTC)