This is an archive of past discussions about Help:Table. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page.
^Countries which do not report data for a column are not included in that column's world total.
^Data on member states of the European Union are individually listed, but are also summed here for convenience. They are not double-counted in world totals.
{| class="wikitable mw-collapsible mw-collapsed"
![[COVID-19 pandemic death rates by country]].
|-
|{{Template:COVID-19 pandemic death rates by country}}
|}
The table reference will show up in the references section of the article it is in. I used {{talk refs}} here to place the references in this talk section.
^Countries which do not report data for a column are not included in that column's world total.
^Data on member states of the European Union are individually listed, but are also summed here for convenience. They are not double-counted in world totals.
{| class="wikitable mw-collapsible"
![[COVID-19 pandemic death rates by country]].
|-
|{{scrolling window|link=Template:COVID-19 pandemic death rates by country|height=150px|title=New articles}}
|}
Unfortunately I may not have time to read through the discussion at present, gotta finish checking my watch list here and on meta, also multitasking with real world stuff. However, I'm fairly certain that the manual of style discourages this usage in articlespace. (please ping on reply)𝒬𝔔16:58, 28 August 2020 (UTC)
Done, however review by a second set of eyes wouldn't hurt; I haven't really done serious css stuff for a few years now and I've managed to make a few (thankfully minor) errors in template coding in recent weeks. I took it a bit more slowly here to double check and I had a bit more time today but it's still possible I missed something.Other than that let me know if there's any other features you want and I'll try to get to them before the end of the month. Courtesy ping to Dudley Miles since you're working on this as well. I'm going to try to be around Sunday at least for 30 minutes if you have any immediate questions, if not you may need to wait until around the 21st to catch me again as the next two weeks should be bit busy for me, thanks. (please ping on reply)𝒬𝔔22:43, 4 September 2020 (UTC)
Is there a way to make the first row of a table (the header) sticky? So that it stays on screen no matter which part of the table is on screen?
Otherwise reading long (and wide) tables is really hard.
Generally this stuff isn't mediawiki specific, but works the same as on other websites. See https://developer.mozilla.org/en-US/docs/Web/CSS/position#Sticky_positioning for details on how position:sticky. That said, I'm not sure how to do sticky headers in a table that's not scrollable (using only css and no js). The Covid template works since the entire thing is in a scrollbox. I'm not fully up to date on recent CSS stuff, so maybe there's a method I am unaware of. Bawolff (talk) 01:11, 3 May 2020 (UTC)
This code will make the column headers and the row headers sticky. If there are no row headers, then omit the "left:-1px;" and "z-index:1;" styles from the first column header. It works in Chrome and Firefox browsers for Windows desktop and Android mobile devices.
Timeshifter. I am currently looking into moving the styles to a CSS file to simplify it for users. I have to do more research on the right way to add the CSS file and see if it should have it's own help page. I have the CSS file on my local and it seems to be working well. I am planning on setting class="sticky-headers" on the table with an optional class="sticky-headers-colrow" on a column header that also needs to be row sticky. Jroberson108 (talk) 22:12, 7 December 2020 (UTC)
(unindent). Jroberson108. Does this work with sortable tables too?
Also, I found this sticky table linked from the Phabricator T42763 thread:
Timeshifter. 1) Yes, it works with "sortable"; although, "sortable" doesn't work for mobile, at least on my phone. 2) The RHCP pages aren't using a table, but a chart table (de:Vorlage:Charttabelle), which looks like a table in a desktop browser, but changes in a mobile browser so that row data is displayed vertically as opposed to horizontally with the column headers listed at the top of the entire chart. In certain curcumstances, this might be a better responsive approach compared to a table; although, their header labels aren't sticky at the top and scroll out of view causing a potential disconnect with the data. 3) It looks like "floatable-header" takes a similar approach to what I did in making column headers sticky, but they didn't do anything with the row headers which scroll out of view causing a potential disconnect with the data. Also, their column headers aren't sticky on mobile, just desktop. Jroberson108 (talk) 04:37, 8 December 2020 (UTC)
Set table column width to 150px
Here's the code. Does anybody know how to set the width of column 3 to 150px? "width: 150px" for column 3 is in the code at the moment, but the browser ignores "width" and "max-width" in any column. The browser only obeys "min-width". I tried "table-layout: fixed", "word-wrap: break-word", and some other things, not having luck so far. Thanks. –Novem Linguae (talk) 16:43, 6 January 2021 (UTC)
Novem Linguae, if you look at the thread just above ("Use of em and % values in preference to px values"), you'll see Warning: Setting specific pixel sizes is deprecated, as it interferes with the ability of the browser to adjust content to suit the browser window, device size, user-end font size limits, and other constraints. It is strongly preferred to use relative sizes, in percentage or em values... Schazjmd(talk)17:45, 6 January 2021 (UTC)
@Novem Linguae: The cells in column 3 use {{nowrap}}. This forces the column to be at least as wide as "People's Front for Democracy and Justice", so setting a smaller width has no effect. Browsers (at least my Firefox) will not respect a large width if it forces the table to be wider than the window, so setting a very large width in column 3 may have no affect unless the window is really wide or you zoom out a lot. On my screen at standard zoom this all means that width is effectively ignored in that particular column of that particular table. PrimeHunter (talk) 22:48, 6 January 2021 (UTC)
It is Bad Form to have hidden content without a clear indication, but the cell could have extra, hidden content and a [show] button:
{| class="wikitable"
|+ Caption text
|-
| Example || Example || Example
|-
| Example
| Example
{{collapsetop|bg="silver"|title=More...}}
Lots more information
{{collapsebottom}}
| Example
|-
| Example || Example || Example
|}
Instead of using absolute pxpixel sizing, prefer relative values with % and em units. Content can automatically shrink to fit.
Instead of specifying a fixed width, consider using min-width or max-width instead. It usually does not make sense on mobile to have a table occupy only 50% of the width.
Doesn't this mean the various examples in this article should comply with that advice?
I can go through and amend if there is no objection and someone can check what I do. But if someone else prefers to do it I won't object. ;-)
SCHolar44, the column width section states Warning: Setting specific pixel sizes is deprecated, as it interferes with the ability of the browser to adjust content to suit the browser window, device size, user-end font size limits, and other constraints. It is strongly preferred to use relative sizes, in percentage or em values.. I came here to see if there was a recent discussion that mentioned it, because the page gives examples using pixel sizes. There's a post from several years ago asking about the same thing, so it's been since at least 2016, but I can't find a discussion that led to the decision. Anyway, I agree that the page should be cleaned up to only use examples that comply with the recommended/strongly preferred guidance. Schazjmd(talk)14:56, 20 December 2020 (UTC)
In Firefox browser I frequently click the zoom buttons in one of the top toolbars to increase or decrease the text size. But I also have "Zoom text only" checked in View menu > Zoom.
So I would not want em values used for images, or border width, or border spacing, or margins, padding, etc.. In other words anything non-text related.
I have gone through the article, as promised, with the following actions:
changed px values to em values (multiplication factor used: x0.077) wherever px values had been applied to content that was not text-related, i.e. images, border width, border spacing, margins, padding etc
changed em values to px where they had been applied to images, border width, border spacing, margins, padding etc
drafted a notice for the introduction to the article and updated the existing (upper) one in the section headed "HTML attributes".
I have pasted the amended article into one of my User pages. To see the changes, just copy the amended article, go into Edit mode in the Help:Table article, Select All and delete, paste in the amended article, click Show preview then Show changes. When you're finished, click on Cancel.
Two questions:
You'll see that in the first place where I have changed the specification to em values, in the code under the heading "Multiplication table", I have only changed to ems for the width value, not the height. However, I see the example under the heading "Width, height" specifies style="width: 60%; height: 14em;". Is there a reason to use em or % for the height?
Should we word the advice to indicate that % or em specifications are only needed for width values?
Please examine/critique carefully, and of course change at your will!
changed em values to px where they had been applied to images, border width, border spacing, margins, padding etc This is the wrong direction. It's bad web design and Timeshifter's opinion on the particular matter is strictly his personal preference. The only thing that is reasonable is that images must be specified in pixel values (this is a web requirement, essentially). (I would also say it's generally not idiomatic to specify border widths in anything but pixels, but that's a question of idiom and not requirement or suggestion.)
Generally, what should be suggested is that inline styling in general should be avoided. class="wikitable" is usually sufficient. Where desired, inline styling should be kept to a minimum. This allows the particular skin in which the table is displayed, and the browser, and lastly the user with his own stylesheets whether onwiki or in his browser agent, maximum flexibility to do what it will to fit the content to the screen. --Izno (talk) 05:44, 18 January 2021 (UTC)
Hmm, I hear what you're saying, Izno. Your knowledge is obviously far in advance of mine; I don't have the background to implement explicitly what you have opined as over-arching principles. I have therefore decided not to carry this further and to delete my draft, knowing that your comparison is still available should anyone (or you) be interested to give clearer guidance on the px/em/% question. SCHolar44 🇦🇺💬 at 11:22, 18 January 2021 (UTC)
Is there a way to make a table in which one row is collapsible and can be made visible by clicking [show] while other rows are always visible? Krisgabwoosh (talk) 20:33, 8 February 2021 (UTC)
parameters and auto-sorting tables
What do the 'create', 'order', 'numeric', and 'ascending'/'descending' parameters and more mean, how do they function, and how do I use 'colspan' and 'rowspan', and use multiple headers or place headers in different locations on Module:AutosortTable, and how do I auto-sort tables and use the 'create', 'order', 'numeric', and 'ascending'/'descending' and the other parameters on tables? -- PK2 (talk) 10:35, 19 August 2020 (UTC)
@PK2: Strictly speaking none of those are parameters. Modules follow the format of
Hence, create is the name of the function being called; order, numeric, and descending (there is no ascending) are arguments.Order is for the sorting preference it takes a coma separated list of column numbers; if two values are the same the next lower preference is used.Numeric also accepts a coma separated list of column numbers; it designates which use numeric sorting.Descending is likewise a coma separated list of column numbers it inverts the normal sort order which is ascending by default.I'm not clear why you would want to use rowspan. Recalling that, post-sorting, any rowspanning cells are cut into individual rows with repeated content and remain that way even if the original sort order is restored.You autosort tables by converting them into the format used by this module (see Module:AutosortTable/testcases for examples) although in most cases I suspect you're better off using a standard sortable wikitable.I apologize if I haven't answered your question in full as I'm not sure I fully understood it; if you are looking for someone to write up the documentation for this module I can potentially do that but my time for this is quite limited at the moment (and I have quite a few things on my plate already) so it may be some time before I can get around to it.(please ping on reply)𝒬𝔔16:58, 28 August 2020 (UTC)P.S. Please allow a few days for replies, I can usually respond within the week.
Hello @PK2: I don't know if you (or possibly others) still care, but I have (somewhat) updated the in-code documentation of the parameters you mentioned (while adding a couple of new items). I have an urge to create proper documentation, that's on an actual /doc page and isn't so terse, but I haven't done that yet (and it may be a while before I do).
In case you haven't already figured out what you were wondering about, take a look at what I've done and see if it helps. I'd welcome any feedback. Regards, — JohnFromPinckney (talk)23:51, 21 February 2021 (UTC)
I have a few questions for everyone:
Can you please make it possible for me to use parameters like 'colspan', 'rowspan', 'nosort' and 'data-sort-type', use multiple headers or place headers in different locations, style all or individual cells, rows, columns or headers, and replace the module equivalent of ! scope="row" with | scope="row" on Module:AutosortTable?
How do I auto-sort tables and use the 'create', 'order', 'numeric' 'ascending'/'descending', 'hidden' and the other parameters, and style all headers or individual columns on standard tables?
Why would someone use the 'hidden' parameter on tables?
I'm not personally inclined to add support for rowspan/colspan, as I'm not completely clear on what all their effects on accessibility are. More relevantly, how is a table supposed to be sorted when cells are joined using such span attributes? I don't think you need nosort for AutosortTable; just don't specify sorting on that column. The styling of rows and columns can be done now, if you only knew how (see my #2). And something (else) I don't know: why would you want to have | scope="row" in an accessible table?
I guess your repeated question here is the answer I was waiting for from you: the documention I added is not sufficient to explain these parameters' use. Okay, I'll try to get up some time/energy and create a dedicated documentation page, with better examples.
This one, I can help you on. Consider a table with different data columns (duh), one or more of which you do not (at the moment) want displayed on a given page (like maybe a list of all the Wikipedia versions, but without the magnitude of the user base displayed). However, you do want the table sorted by one of those hidden columns (for example, with EN-WP at the top, 'cause it's the biggest/has the most users).
I see that you can center a normal table with align="center" in the heading, but this doesn't seem to affect wikitables. Are wikitables always left-justified? --DawnDusk (talk) 17:20, 4 March 2021 (UTC)
I found it. One must use style="1em auto 1em auto" to center it. I found this on the Simple Wikipedia's help page, actually - perhaps it's worth porting here? --DawnDusk (talk) 17:28, 4 March 2021 (UTC)
(unindent). This page is fairly up to date (November 10, 2020):
It says align="center" has been deprecated in HTML5.
It says to use CSS, and to set margin-left and margin-right values to "auto". Top and bottom margins can be set to whatever you want. Using your values, here is the short version:
style="margin:1em auto;"
1em is for top and bottom margins. Auto is for left and right margins.
Here it is added to the table from the insert table button on the editing toolbar:
Caption text
Header text
Header text
Header text
Example
Example
Example
Example
Example
Example
Example
Example
Example
{| class="wikitable" style="margin:1em auto;"
|+ Caption text
|-
! Header text !! Header text !! Header text
|-
| Example || Example || Example
|-
| Example || Example || Example
|-
| Example || Example || Example
|}
Probably several. First (the question to always ask at the beginning): of what information is this a table? What "stuff" are you trying to show? For example, what does the "1.1" under the first "%" heading indicate? What are the percentages precentages of? (This question leads both to ideas about how to present the data and to formulating a caption, which this table lacks.)
Second: what is the connection between "Wan Chai", "Kwun Tong", and "Sha Tin"? They are all in the same table row, but why? If there is no connection, then I suspect you really need four separate tables, one each for HK Island, Kowloon, NT and "Islands" (although it seems that Hong Kong Island must be an island, no?). And what is the cell with the lonely little hyphen under "Islands"? — JohnFromPinckney (talk)11:26, 30 March 2021 (UTC)
The percentages next to each cell are indicating the percentage of the population which was recorded in the census to be able to speak Shanghainese.
"Wan Chai", "Kwun Tong", and "Sha Tin" have no relation, hence why there isn't a header on the left side; they are just coincidentally next to each other. The chart is meant to be read top-down but I can see how it isn't obvious to some. Is there some easy way of making the divider between rows thicker?
I believe "Islands" supposed to be Islands District, which is officially part of the New Territories region today, I'm not sure why my source has it as a separate region from the three other main regions, the other two being the main Hong Kong Island and Kowloon (which is physically connected to mainland China). The dash just shows that there are not subdivisions to be listed under "Islands".--Prisencolin (talk) 07:09, 31 March 2021 (UTC)
First of all, I have to apologize for not knowing the proper divisions of Hong Kong; I am bewildered by what my quick web browsing has turned up regarding geopolitical divisions. Even Wikipedia does not make clear for me (skimming hurriedly) what the three "things" (Hong Kong Island, Kowloon, New Territories) are: regions, districts, areas, ...? There appears to be an island and a peninsula, but I'm not clear what's what, so you will have to check for correctness. The "Sheung Wan", "Wan Chai", "Kwun Tong" items seem to be districts or parts of districts, so I've just sort of half-guessed and leave the details to you.
So, then: I have taken the liberty of making a "live demonstration" of a starting proposal on the page itself (Permalink).
– I split the data into three tables, per your point 2 above, one for each, um, region. The "Islands" column you had seemed so minimal, that I relegated the 0.5% to a note at the bottom, as there's not much to tabularize.
– I added the wikicode appropriate for WP:ACCESS, with captions and scope attributes, and right-alignment for the percentages. The caption for the first table has <br /> tags as a small hack to nudge all three tables to have equally high (in line numbers) captions, for the appearance of tidiness. The three tables I have placed in columns (assuming a wide enough display) using {{Columns-start}}, which should responsively collapse for narrower displays (like phones).
– The tables remain (now independently) sortable.
– I also smushed the statistical stuff a little closer together, although I'm not sure how much it means to our readers there. You can, of, course revert all or some of my changes; I hope they constitute an improvement (or at least a learning/discussion opportunity), but do not have to be permanent. — JohnFromPinckney (talk)16:54, 31 March 2021 (UTC)
Is rowspan broken?
See the example below. Hoover (left column) and Nixon (right column) should overlap.
Hoover can't get to Nixon because Ruckelshaus is in the way. Haldeman and Ehrlichman are being kind of obstructive, too. Heh, heh.
Seriously, how can Hoover span four rows, as you've specified, when you've said Ruckelshaus needs to be in there, too. Something has to give, and the compromise is that all cells remain inside the table. It's actually a reasonable fallback solution, considering how easy it is for humans to miscount rows. — JohnFromPinckney (talk)20:45, 1 April 2021 (UTC)
Need some kind of invisibility powder to sprinkle on the border between the 2 Hoover cells. And need to sprinkle some on the second Hoover. --Timeshifter (talk) 06:30, 2 April 2021 (UTC)
Invisible borders would be bad here, e.g. giving wrong results for screen readers. rowspan is not broken but a row will usually render with height 0 if there is nothing to display in the row. You can force a minimum height on a cell with style="height: ...em;" Don't use px which varies too much between users. Below I used 3em on Nixon. It works for me but it may fail to overlap with Hoover if the Ruckelshaus row gets two lines. I don't know a general method which will always work. PrimeHunter (talk) 11:17, 2 April 2021 (UTC)
Name
President
J. Edgar Hoover
Harry S. Truman
Dwight D. Eisenhower
John F. Kennedy
Richard Nixon
William Ruckelshaus
I would still qualify that behavior as broken -- there is a use case where it's valuable to display such overlaps even if technically "there is nothing to display in the row". Additionally, in other cases which are equivalent to my eye the overlap does render. But your workaround does do the job. Thanks! Jpers36 (talk) 11:46, 2 April 2021 (UTC)
If it's "broken" then it's broken by html and not by MediaWiki. rowspan is html. Browsers only display table cells large enough to fit the content and specifications. It's the same outside wikis. PrimeHunter (talk) 15:03, 2 April 2021 (UTC)
Need converter of 2-letter state abbreviations to full names
Such a converter, or regular expression, would make editing some state list tables much easier. Here is an example:
I fully replaced the data for all years for the state overdose death rates and counts here:
LibreOffice Calc put the pivot table in alphabetical order of those 2-letter abbreviations. But that is not the same order as the full state names.
So I had to manually move the rows around in the Visual Editor. Then I could paste just the data next to the column of full state names.
I need a converter for the csv text file or the mediawiki table. Maybe a regular expression I could use in the wikitext editing window source editor. --Timeshifter (talk) 13:06, 9 April 2021 (UTC)
Syntax for scope and style on same line
I've got a table where I want to specify style on the header lines. The table documentation says to use scope=col for headers. If I specify only scope or only style, everything seems to work. However, if I specify both, then it takes my style specification as header text, e.g., I get a column header of style="max-width:14em;" | Announced from
Thanks: I used maxwidth to leave as much room as possible for the Name column; some of the product names are longer then the ones I posted here. I used "|+" more to keep "Hide" from going in a column header than from any real desire for a caption, especially since wiki formats the caption for a very narrow line width when the table is collapsed: I may see how it looks with a blank caption.
Is the purpose of the mw-foo to make the table sortable?
Don't know anything about metadata. The mw-foo is just what I have been using for collapsible tables. I think it is the more recent class for collapsible tables. See also: MW:Manual:Collapsible elements.
Your max-width settings were not effecting the columns with dates and numbers, because those dates, numbers, and headers were already short. So screen width will not effect them first. In fact the individual header words can not wordwrap. The wordwrap would occur between the word and the hash tag.
Before that happens the product name column would wrap.
I haven't figured out a way to spread out the caption of a collapsed table.
You could use my previous table that put the caption in a wide header. Then change the column headers to plain table cells. So they wouldn't show in the initial collapsed table:
Secondly, please don't use collapsed, as it, too, limits accessibility, as explained at MOS:DONTHIDE.
Thirdly, Timeshifter is right about max-width; you don't need it, and it's generally better to not constrain columns, because some user is going to come along with a different user-agent than you have and see things different than you do, anyway. In general, let the data determine the widths. In this case, the long product names will automatically consume as much space as available before breaking into multi-line display; I'd say that's exactly what you want.
And finally, Chatul, you were on a good path by using |+ as you did; tables usually should be captioned, and you've got a good caption to use. Try:
(Unindent). Another possibility is to go ahead and collapse the table, but link to a page with the expanded table. This is done for some of the partially collapsed tables in this popular article (in the Statistics section):
I thought of a way to show just the table caption in spread out form. I had forgotten about class=nowrap for the caption only. You could even add a caption border and padding. The table still wordwraps as the browser window narrows.
For background, User:Chatul/References#Timeline is part of User:Chatul/References, which contains notes to myself that I may want to excerpt from when editing articles relating to, e.g., IBM software. It may be useful to others, but most likely only for copying text and markup. I would expect users of this material to only read enough to identify the material they want to excerpt. I tend to collapse tables there so as to not obscure other content. Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:18, 21 May 2021 (UTC)
If you do some of this stuff on other wikis, then you may need to use style=white-space:nowrap to spread out the caption text when the table is initially collapsed. class=nowrap is not on all wikis. --Timeshifter (talk) 15:56, 21 May 2021 (UTC)
You suggest again to go ahead and collapse the table, despite the accessibility problems I mentioned?
If you're going to hide the table anyway and point to another page for all the data, why not just omit the collapsed table completely and point to another page for all the data?
I don't believe partially collapsed tables pose an accessibility problem.
You thought of a way? I already included class=nowrap in my example above yours.
Chatul has since pointed out that their target is a user sub-page, where I think collapsed tables aren't quite so egregious (and I've got some collapsed-by-default content on my user page, so I'm no saint myself). I just wish to avoid recommending or condoning the use of content that some users cannot access. It certanly shouldn't be in mainspace articles. — JohnFromPinckney (talk)16:30, 21 May 2021 (UTC)
I don't see an accessibilty issue for a user subpage with this use case. Putting the data on another page would make it more awkward to copy from multiple places.
(unindent). John. You wrote: "I don't believe partially collapsed tables pose an accessibility problem." Is this official MOS policy? Can you show me where it says that? Do screen readers see the underlying table somehow because it is only partially collapsed instead of fully collapsed? If so, that is great. I will use more partially collapsed tables in articles. I can think of many cases where it would be useful.
Actually I would like to see the references for this. I find the MOS to be out of date at times concerning access issues.
John, I did not notice your use of nowrap before I thought of it. You need to reread WP:AGF. --Timeshifter (talk) 02:30, 22 May 2021 (UTC)
A little help
Hey, can I get a little help with a type of table I want to create? It's the inverse of the example on #Floating table. I've uploaded an example of what I need on imgur: https://i.imgur.com/esAYjjV.png. I'd also suggest someone put the answer in the main help page so other people who might not understand find it. Thank you. --81.196.174.24 (talk) 00:38, 12 June 2021 (UTC)
Nevermind, found the solution after some fiddling. Posting here in case someone needs it.
Looks like rowspan=2 is working for you. This below will work too if you don't want 2 separate cells for 4 and 5. It just puts a break between 4 and 5.
1
2
3
4 5
6
7
In rows where you have set the height (see Help:Table#Height) the text is centered vertically by default. You can align the text to the top or bottom via style=vertical-align:VALUE for the whole row, or for individual cells.
Thanks for the replies. No, I most definitely wanted two separate cells, I wanted 4 and 5 to be able to be sorted as different cells, in case I had several more instances in other rows of 4 and/or 5 and the readers wanted to sort either by 4 or by 5, if that makes sense. There's a reason I put "sortable" in my example.
Looks like rowspan=2 is working for you.
Ah, rowspan was the first thing i tried, I just didn't know how to get the 5 below the 4 without breaking the table. I would just put it next to the 4 in the code and it'd make a new column or something. --2A02:2F07:B10C:E300:7144:16E6:515C:6CA3 (talk) 11:14, 12 June 2021 (UTC)
While I'm here, I don't suppose there's a way to integrate that 4 next to the 5 in the table's code? For example, if I wanted to make this,
In § Side by side tables, it instructs to add the html tag <ul> (unordered list), and further states that if the user wishes their tables to be fully left-aligned, to substitute <ul style="margin-left:0px;"> in place of the plain tag. Wouldn't the same no-indent result be achieved by omitting the UL tag entirely, or will there be some effect that's displayed when more that two tables are horizontally stacked? — CJDOS, Sheridan, OR (talk) 20:16, 26 May 2021 (UTC)
The reason why I said what I did above, is because I was playing around with the idea of horizontally stacking two tables below a third table, and noticed that to my annoyance, the side by side tables were indented off the left margin. I eventually learned what the initialism UL meant in the html tag, and when I removed the Unordered List tag, my side by side tables aligned left without any indentation, exactly as I wanted. I ultimately didn't use side by side tables in what I was working on, but I thought maybe the Help:Table page needed an update. Give me some time to construct example tables here, and I'll have an demonstration for you. — CJDOS, Sheridan, OR (talk) 18:06, 27 May 2021 (UTC)
I made the bottom-left tables collapsible, because this was the layout is what I was working on, but otherwise is irrelevant to the concern raised.
Notice in the above example, the left table is indented off the margin. The table directly above it which is not horizontally stacked, is not indented (for comparison of how it should look).
Example B
Side by side tables, without Unordered List tag:
Year
Africa
Americas
Asia & Pacific
Europe
2014
2,300
8,950
9,325
4,200
2015
2,725
9,200
8,850
4,775
Year
Africa
Americas
Asia & Pacific
Europe
2014
2,300
8,950
9,325
4,200
2015
2,725
9,200
8,850
4,775
Year
Africa
Americas
Asia & Pacific
Europe
2014
2,300
8,950
9,325
4,200
2015
2,725
9,200
8,850
4,775
In the above example, none of the tables have indentation, because I removed the <ul> tag. Help:Table currently suggests that to achieve this result, I should add <ul style="margin-left:0px;"> rather than removing the Unordered List tag entirely. I'm sure there's a reason why the Help page is written that way, but I wanted to inquire about this. — CJDOS, Sheridan, OR (talk) 18:29, 27 May 2021 (UTC)
I should add that if I copied the relevant section of Help:Table as it is shown currently, the tags have line breaks between them, which I did not include here. If I had, then the side by side tables would have padding between them. The above examples is how I was doing it (without padding), and I didn't want the padding confused for margin indentation. — CJDOS, Sheridan, OR (talk) 18:36, 27 May 2021 (UTC)
Simplifying so I can visualize this better. Cleaned up some formatting too. I added a space after the first instance of </li>
@CJDOS and Timeshifter: The <ul> is there because it is required for valid HTML. List items (<li>) are children of lists (as the name should lead you to expect). Lists are marked up as <ul> (for unordered lists) or <ol> (for ordered lists). If you need links to Internet reference works beyond our own articles just say so and I can plunk 10 or 20 here pretty quickly; otherwise GIYF. Therefore, the ul elements you removed should be readded.
Also, Timeshifter: please revert all of your unexplained removal of the quotation marks enclosing the property lists in the wikicode, like:
The quotation marks are only necessary if there is a space that needs to be enclosed by the quotation marks.
Wikitext is not HTML. So unless you can point to a problem caused by not having the <ul></ul> tags, then they are not needed.
I looked at the example side by side tables and images in Help:Table. In Firefox, Chrome, and Edge. In both desktop and mobile view. I narrowed the browser windows until the tables and images wrapped to the next line. They are working perfectly. And better than before because there is no indentation. --Timeshifter (talk) 23:36, 27 May 2021 (UTC)
Response to first two lines, originally from 23:22: I realize you don't care about anybody else but yourself and all you want to do is slap some code together that looks to you as though it works in your operating system on your device at your resolution, but as one of the ten most frequented websites in the world we owe it to our readers to provide exemplary code and explanations whenever we can. That means using correct semantics and syntax and trying to provide valid output usable for the greatest number of users. It means producing (or trying to produce) valid HTML, accessible content, responsive displays of information, etc.
The lack of <ul> produces invalid HTML. I suggest you trying running your variant of the page through the validator at https://validator.w3.org/ and comparing the number of errors found with the version which uses elements and syntax correctly. There are errors either way, unfortunately, but a few more with the ul tags missing. I cannot point to a case where some nuclear power plant suffered a meltdown because quotation marks or <ul> were omitted; I do believe, however, that it is thoughtless to omit the usual details with the excuse that there's currently no space in some style attribute, and it's quite ridiculous, IMO, that you went out of your way to remove quotation marks in correctly formed code. We do our readers and other editors a disservice by showing "seems-to-work" code instead of giving them examples they can follow without problems.
It is true that wikicode is not HTML, but by adhering to coding standards—other pages, and even other places on this same page, use scope="col", for example—we enhance readability and increase the chance of working/valid code (for all users), and reduce the amount of time that gets wasted when somebody tries to add a second property-value pair to a style attribute that doesn't work, because there were no quotation marks previously. Let's try to provide good, robust examples instead of (in case this is what you were aiming at) saving the space of a few quotation mark characters.
Response to last line, from 23:36: Congratulations. I don't give a damn. I'm talking about valid code and clear examples, not whether you think it works perfectly on your machine at this time. Try to see past your own display boundaries. — JohnFromPinckney (talk / edits)23:55, 27 May 2021 (UTC)
Please do not edit other people's comments. It is against WP:TALK. I removed your comment from the middle of my comment. And please stop making personal attacks.
There have been infrequent discussions about this over the years. And you are making the same mistake others have made. I have been editing this help page for years. Others try to insist that Wikipedia editors must use XHTML or HTML or XML. They are all wrong. Wikitext is not HTML, XHTML, nor XML.
A space in a parameter value necessitates the use of quotes around the value. That is true also in HTML. Look it up. --Timeshifter (talk) 00:11, 28 May 2021 (UTC)
And I have now removed your comment from the middle of my comment. In future, please try to leave your comments as they are once you've signed them. It's hard to know when you're "done" so that the rest of us are allowed to converse with you. I have readded your original timestamp to your original comment, to which my first response is aligned. My second response follows your later addendum, which still has the later timestamp.
Please, please stop going on about how you are right because you have edited this page before. It is really off-putting, and proves nothing useful. I do not insist that editors must use XHTML (or HTML or XML); what I do want is (1) consistency and (2) valid HTML as output. Your refusal to recognize the fact that HTML requires <ul> as a parent for <li> is disheartening, especially when you say you have been editing this help page for years. Longevity isn't what's important here, correctness is. — JohnFromPinckney (talk / edits)00:24, 2 June 2021 (UTC)
I apologize: I did not intend to start a heated debate. I would recommend putting the article back the way it was before my inquiry, until this can be properly confirmed. I only noticed an issue with side by side tables being indented from the margin, and the solution that I came up with appeared to me to fix the problem without complicating it with more code. The crux of my question was if <ul> was there for a reason, despite what results I might have achieved on my own display by removing them. — CJDOS, Sheridan, OR (talk) 00:48, 28 May 2021 (UTC)
No need to apologize. JohnFromPinckney makes comments around various table talk pages, and contributes both good and bad ideas. As we all do. But in this case he is flat wrong. --Timeshifter (talk) 01:00, 28 May 2021 (UTC)
I agree with Timeshifter: you needn't apologize. (I disagree that I am flat [or contoured] wrong, but that's a separate matter.) In fact, there is a reason for <ul>, it's because it's part of valid HTML. I'm sorry I didn't get to answer your question sooner before Timeshifter became so active. I try not to cross paths with them, and was holding back. Not your fault. — JohnFromPinckney (talk / edits)14:28, 28 May 2021 (UTC)
I think we should make valid html but I suggest to simplify the coding for editors by hiding it away in three new templates {{Wrap tables begin}}, {{Wrap tables mid}}, {{Wrap tables end}}, instead of the complicated:
<div><ul> <!-- The <div><ul><li> code displays tables side by side when window width allows it -->
<li style="display: inline-table;">
...
</li> <li style="display: inline-table;">
...
</li>
</ul></div>
It would if you used scope attribute properly. Replace the style=text-align:left with scope="row" on each row header (and while you're at it, add scope="col" to the column headers) and you'll get the results you want. — JohnFromPinckney (talk / edits)20:09, 1 July 2021 (UTC)
And now a not-irrelevant question: is the "number" on that table the most important thing about each community area? Or is it the name? It seems that the names are treated as row headings, meaning they're the most important, but the numbers are in the first column, as if they should take precedence. I'm uninformed on the article's topic, but it appears to me that the numbers could (and should) be moved to the second column, with the row headers (<th> generated by ! and scope="row") applied to the first column, as readers (and some editors) expect. — JohnFromPinckney (talk / edits)20:09, 1 July 2021 (UTC)
Hello, I've notice that the mw-datatables are not working (they might be elsewhere, but just not in this article, I haven't checked yet — but I can't find what is wrong with the table in this article). Can someone else spot what is wrong? I'm using Firefox on Windows with the default legacy skin, by the way. Thanks. — Eric0892 (talk) 04:39, 13 August 2021 (UTC)
Can you clarify what you mean by "not working" and "this article"? Are you talking about this section of Help:Table? In any case, do the notes about is not working in some skins and the phab tickets listed in that section relate to your "not working"? — JohnFromPinckney (talk / edits)12:33, 13 August 2021 (UTC)
The samples in that section are not working. As to the skins issue, I was always using the default skin and it did work a few days ago. I'll add that to the Phabricator issue. — Eric0892 (talk) 18:04, 13 August 2021 (UTC)
wrong sort order between negative numbers differing in decimal places in wikitable sortable
I've been sorting this table by the last column and there seems to be an issue with the decimal places in negative numbers- The ascending sort actually descends from negative 0.001 to negative 0.012 and then jumps to the positives. It does not seem to be connected to the "increase" and "decrease" macros. -- Theoprakt (talk) 09:20, 23 October 2021 (UTC)
Items in the last column of that table use {{increase}} or {{decrease}} followed by a number. In the HTML source for the article, typical items look like this:
Sorting puts all the "Decrease" items together (before "Increase") then sorts by numbers. The fix would be very ugly and involve Help:Sorting#Specifying a sort key for a cell. Apart from the wikitext bloat, the really ugly feature is that each number would have to be duplicated which is a maintenance nightmare. Johnuniq (talk) 09:42, 23 October 2021 (UTC)
Thank you. So the macros turn the sort to alphanumerical, which is why even after inserting minus signs the sort order is wrong. -- Theoprakt (talk) 10:38, 23 October 2021 (UTC)
Ok, I tried Chrome & it looked fine. In firefox, the table is missing right border lines after all 3 of the "Header text" phrases & a border line between the "header text" & the rest of the table. I must need to download some updates unless others have the same problem. Thanks for troubleshooting for me. Rgrds. --Bison X (talk) 22:11, 28 October 2021 (UTC)
Bison X. If that doesn't work, you might want to completely uninstall Firefox and all your addons. Then do a clean install of Firefox without addons. See if that works. Then add one addon at a time, and see if the problem shows up again. --Timeshifter (talk) 22:45, 28 October 2021 (UTC)
PrimeHunter. I just activated that preference and the internal header borders disappeared in the table in this thread. I am still using Firefox on Windows 10 Pro. See related problem:
I am in source mode. When I click the table icon (under Advanced) on the editing toolbar this is what shows up:
{| class="wikitable"
|+ Caption text
|-
! Header text !! Header text !! Header text
|-
| Example || Example || Example
|-
| Example || Example || Example
|-
| Example || Example || Example
|}
This is what you get when you save it ("publish" button):
Caption text
Header text
Header text
Header text
Example
Example
Example
Example
Example
Example
Example
Example
Example
You can fill it in while in source mode. Or use the Visual Editor (VE). With VE you directly fill in the cells without having to fool around with wikitext.
The Visual Editor is not available for use on discussion (talk) pages. You can experiment with it on your user page or user sandboxes. See the VE section at the end of Help:Table. VE makes it easy to add or delete rows or columns.
This page says "nested tables should be avoided whenever possible" (Help:Table#Nested_tables), but implements nested tables for all the "Rendered result" parts of the page. This doesn't render nicely on smaller devices and should instead float under its "Wiki source" counterpart on smaller screens. You could instead use markup similar to this which is responsive:
@Timeshifter: Yeah, I saw and updated [T42763] for sticky table headers. I may be mistaken, but votes at this point might be meaningless since votes are probably what created the phabricator tickets to begin with; although, it might bring more help for implementation. Jroberson108 (talk) 08:51, 30 January 2022 (UTC)
Is there any information on a possible Wikidata integration that this page is missing? Like, if an editor wants to create a comparison table of items of a same instance on Wikidata comparing certain statements?--Iara Ai (talk) 19:04, 12 January 2022 (UTC)
The page is mostly about how to make tables, not where to get content to put in them. If you want a table dealing with Wikidata items, you will have to find out (for yourself, or with help somewhere else) and then put that info in a table (which this page is intended to help you with). — JohnFromPinckney (talk / edits)02:19, 13 January 2022 (UTC)
How can I get the following table to floatright? 'class="wikitable floatright"' does not perform as I expected from reading this documentation:
{| class="wikitable floatright"
|-
| || colspan="2" | [[File:Humility and arrogance.png|150px|center]]
|-
| || colspan="2" | Humility and Arrogance
|-
| || How do you know that? || I know the truth.
|-
| In armed conflict || How can we protect ourselves without escalation?
| Collateral damage is unfortunate but necessary.
|}
Humility and Arrogance
How do you know that?
I know the truth.
In armed conflict
How can we protect ourselves without escalation?
Collateral damage is unfortunate but necessary.
ALSO: Is there a way to specify imagesize in "em" units rather than pixels or "thumb"?
The section on "Wikitable as image gallery" begins, "This section is still recommending deprecated fixed-pixel sizes for images, and should be updated with relative sizes in em units." Is there a way to replace, e.g., "150px" with a specification in "em units"?
I don't think we need one long table with 2 columns, creating excessive whitespace. What would be the best/preferred solution to this- splitting the tables in question into two separate tables (for example, two/three 2x17 tables) or keeping it as one table, but changing the amount of columns instead?
In regards to the 'locations' table, I'm talking about something like this:
@Magitroopa: Per MOS:NO-TABLES, since the "Locations" table doesn't need sortable and the structure and data are simple (i.e. "year" is recognizable without label), you could convert it to a list and use Template:Columns-list to wrap it into columns. Not sure why 1994 has two locations?
@Jroberson108: I think combining the sections/tables might actually be best here, as opposed to the current two long tables. So maybe instead having a 'List of ceremonies' section followed by the table briefly started above, and then subsections within for 'Locations' and 'Host' that would give the prose text currently listed in those sections.
And FYI in regards to two locations for the 1994 show- that's because the main show/ceremony was held at the Pantages Theatre with Lawrence & Cameron hosting, along with an east coast 'portion' from Universal Studios Flordia, which is where Weiner hosted from with an audience + some performances there as well. Magitroopa (talk) 01:30, 17 March 2022 (UTC)
@Magitroopa: Based on the info you provided, I adjusted 1994 in the table above so it is apparent who hosted where. Also, commas now separate hosts since names can wrap in middle on small devices. Jroberson108 (talk) 01:55, 17 March 2022 (UTC)
Why "Why <nowiki>"?
The Nested Tables section says Why <nowiki>, seemingly out of a clear blue sky, and then doesn't say anything about <nowiki>. That apparently appeared in this June 13, 2020 edit but I'm not sure what it was intended to convey to the reader then or is intended to convey now. I came here to try to get a handle on hidden tables, and I am pretty foggy on the details of that even without wondering what I'm missing because of the Why <nowiki>. I looked at the wikitext around that in the current page version, which says:
* Why <syntaxhighlight lang="moin" inline><nowiki/></syntaxhighlight>. <!-- Removing the <nowiki/> above to see. -->
but that didn't help much. I tried removing the <nowiki> preceding that line and refreshing the page, but that didn't help either. Does this need to this be clarified, or am I just exceptionally dense this morning? Wtmitchell(talk) (earlier Boracay Bill) 10:11, 8 April 2022 (UTC)
You're right, there was no need for it. In fact there was no need for that example at all. Nesting tables is discouraged, and there is a far simpler example beneath it which adequately explains the technique in case it was ever needed. --Jules(Mrjulesd)15:52, 10 April 2022 (UTC)
/** * wikitable class for skinning normal tables * keep in sync with commonPrint.css */table.wikitable{margin:1em1em1em0;background-color:#f9f9f9;border:1px#aaasolid;border-collapse:collapse;color:black;}table.wikitable>tr>th,table.wikitable>tr>td,table.wikitable>*>tr>th,table.wikitable>*>tr>td{border:1px#aaasolid;padding:0.2em;}table.wikitable>tr>th,table.wikitable>*>tr>th{background-color:#f2f2f2;text-align:center;}table.wikitable>caption{font-weight:bold;}
You could use a TemplateStyle to adjust this to how you like, and then apply it to your table.
@Mrjulesd, the problem is that I'm really bad with CSS editing so I wouldn't know how to do that in practice. :/ Is that an easy/fast thing to do? Maybe you can do it for me and I can save it somewhere? I just wanted to remove the frame (4 lines: top, bottom, left and right) that outlines the table while keeping everything else intact. - Klein Muçi (talk) 09:31, 21 April 2022 (UTC)
(reply not indented to save confusion) One quick solution would be to add a third column on the left (with a fixed width) to provide the indent.
Before table.
Thanks! The second approach seems to be more adequate, since it uses "natural" indents instead of a hard-coded number (which might be different in different skins and might change in future).
If this effect (demonstrated in my first example) is indeed a bug in the parser, maybe it should be investigated and repaired? At least, it would be very useful to mention such problems and workarounds in the help.
And by the way, is there any reliable way to include tables in nested lists in general? For example, tables don't work "as is" even in simple bulleted lists:
(This reply also not indented in attempt to avoid confusion)
It seems that the wikiparser does not close off list items (<li></li> and <dd></dd>) after a table. That's why the After table. Should not be indented, but it is. in the OP's shaded bit is indented; it's (still) part of the <dl><dd> content initiated by the colon just before the table. I did some other tests with an HTML table (<table><caption> etc., not wikimarkup like {| class="wikitable") inside an asterisk-generated bulleted list, and the results were similar; my table appeared nicely, but everything following it (inside or outside my bullet list, including headings) was indented, as part of the identation accompanying the table's list item.
For the basic question asked in the OP, I would consider just adding styling like {| class="wikitable" style="margin-left:4em"
Introductory text.
Caption text 2a
Header text
Header text
Header text
Example
Example
Example
Example
Example
Example
Example
Example
Example
Concluding text. And I realize I'm not using nested tables as mentioned in the original question, as that aspect doesn't really seem germane; it's rather just the problem of a table in a list item.
And as far as the later question goes, about putting a table in an unordered list, I was unable to make it work using asterisk markup, and didn't even try with your {| class="wikitable" coding; I got good results only by forcing the list-item closure by inserting the HTML directly (um, that is, both list markup and table markup, manually; click edit to see my code):
I introduce this list of items, the third of which is a table.
Item 1
Item 2
Caption text 4
Header text
Header text
Header text
Example
Example
Example
Example
Example
Example
Example
Example
Example
Item 4
And now some concluding text. Happily, it is NOT indented.
Now, while this allows things to "work" on some discussion page, I can't say it's really practical.
How can you make column 5 appear with the same height as the first 3 columns? I use "rowspan="2" but it would not work. I don't want that blank space on top of it. Thanks!--TerryAlex (talk) 19:47, 16 May 2022 (UTC)
The advice on indenting tables is bad. A leading colon does not indent; rather, it produces a description list, but without a term, which results in invalid HTML. "The way you'd normally indent anything" is NOT by using a colon, but by using {{block indent}} or CSS. Trying to "indent" something in the middle of a list results in mangled HTML with lists opening and closing repeatedly, which is a disaster for accessibility. Hairy Dude (talk) 18:59, 17 May 2022 (UTC)
Column wider for one row only?
Hello, I'd like to create a table that looks like this:
§
page
1
Lorem ipsum chapter title
42
I.e. the title of the last column should extend to the left as much as it needs space even over the otherwise more narrow width of the column. To create the table above I've used the "colspan" attribute, but that means that the column title is no longer associated to the last column which I assume will be bad for screen readers.
Do you have an idea how it would be possible to get the visual result without destroying the logical structure for screen readers? Thanks a lot in advance, --Marsupium (talk) 09:19, 7 June 2022 (UTC)
Thanks for your answer! Using abbreviations isn't an option cuz the use case is the transcription of a book on Wikisource so should match the original, see here for a scan of the original. I've done some search on using a "scope" attribute and a workaround could be to use it and set the "dir" attribute of the table from right-to-left, but that sounds like a messy solution, so I guess I might simply have to live with the column remaining slightly wider than desired. :-) --Marsupium (talk) 10:44, 7 June 2022 (UTC)
@Marsupium: This is a help page for the English Wikipedia. I meant no proper way here. Maybe Wikisource accepts more manipulation to try to follow source layout. You can try something like <div style="position: relative; right: 2em;">page</div>. The number can be varied. Don't use px, it relies too much on circumstances for the viewer. The suggested code can also depend on circumstances so you may want to test with different browsers, zoom levels and font sizes if you care about the precise result. PrimeHunter (talk) 11:25, 7 June 2022 (UTC)
Sorry, I should've mentioned that the use case isn't here with the question! Thanks for the the position: relative workaround, it could indeed work. But I think now I've even found a clean solution using id and headers attributes as described by MOS:DTT#Complex tables. (Noting it here as reference for the next one running into a similar problem.) Thanks a lot again! --Marsupium (talk) 11:51, 7 June 2022 (UTC)
How to "wrap" a table based on the device width?
The following table (with {{football kit box}} templates inside each cell) looks fine on desktop view. However, on mobile view, horizontal scrolling is needed to view all the cells. I've been told that scrolling is discouraged. How can I fix the issue? Nehme149922:23, 14 June 2022 (UTC)
Monza's first kit in 1912 was blue-and-white.
In 1920 the kit changed to blue-and-white halves.
The first red-and-white kit appeared in 1932.
In 1937–38 and 1961–62, Monza wore stripes.
Variations of a full-red shirt were worn between the 1930s and 2010s...
...which alternated with the white-stripe kit, first introduced in 1971.
I haven't been doing as much on Wikipedia, so I will not be of much help on this topic, but I thought I could at least make a more direct link. So others might be able to help more easily.
I was wondering how I could request help on creating a table that would look like this although where I do not have to input the spacing numbers?Patapsco913 (talk) 21:01, 22 August 2022 (UTC)
A workaround to have sticky/freeze headers to a scrollable wikitable.
I made a workaround which handles the sticky headers issue, simply by using some easy to understand html and css code. I do not know if it works for any case (different browsers, various versions etc) but we can have a discuss here. You can make a wikitable with freezed header and a scrollable data body, by creating two tables, one exactly under the other, touching each other. The first will be bare, without data, just holding the header labels and the other will hold the data without having a header. The second should be kept within an html div, having a specific height (in my case 25em), which will add the scrolling effect. The two tables should be created in such a way that they should somehow be synchronized regarding their column widths, in order to give the illusion of being a single table. Put 0px margins between them and hide the first row's top border, to avoid the double line effect. You can try it by running the code below:
(Note: I am not a web developer, some things may be implemented more efficiently, like making classes to avoid adjusting the column widths twice, but anyway...)
==Test Table==
<div style="display:grid; grid-template-columns: auto;"> <!-- The main div -->
<div style="width:100%;"> <!-- The div holding the header-only table -->
{| class="wikitable" style="width:100%; margin-bottom: 0px; table-layout: fixed;"
|+
<!-- Give the desired names and widths to your labels -->
!style="width:10%;"|Column 1
!style="width:20%;"|Column 2
!style="width:30%;"|Column 3
|}
</div>
<!-- The scrollable area. Set the desired height here (eg 20em) -->
<div style="height: 20em; overflow: auto;">
{| class="wikitable" style="width: 100%; table-layout: fixed; margin: 0px; overflow-wrap: break-word; word-wrap: break-word; border-top-style: hidden;"
<!-- Put the first table's column widths to the first row's cells (eg 10%,20%,30%) -->
|style="width: 10%;"|Test
|style="width: 20%;" align="center"| col data 2
|style="width: 30%;"|BIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIG
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| GBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIG
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|GBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIGBIG
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell. DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|-
|[[Test Data Col 1]]
|align="center"| Test Cell Data col 2
|[[Test Data Col 3. Can ne larger than the others.]]
|}
</div>
</div> <!-- This part imforms the user that he/she can scroll. Copy it as it is -->
{| class="wikitable" style="margin: 0px; background-color: white; width: 100%;"
|align=center | scroll down to view all records ↕️
|}
</div>
The heading is "Candidates" and I see the problem. It looks like phab:T88220 from 2015 tried to fix it but was declined. Below is an example with a simple table only using class="floatright" and plain text. PrimeHunter (talk) 00:35, 14 November 2022 (UTC)
Header
Header
Header
Header
Header
Header
Header
Header
Header
Header
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Example
Subheading 1
Text under subheading 1.
Subheading 2
Text under subheading 2.
Eliminating borders for last column
I'm attempting to create a table with text to the right of the first and last rows. I attempted to use
{| class="wikitable"
|+ OS/360 storage layout after IPL and NIP
|-
! Content
! Area
! style="border-top: none border-right: none border-bottom: none" |
|-
| Link Pack Area (LPA)
| style="text-align: center;" rowspan=2 | Common area
| style="border-top: none border-right: none border-bottom: none" | Highest
|-
| Master Scheduler Region
! style="border-top: none border-right: none border-bottom: none" |
|-
|
| style="text-align: center;" | Dynamic area
! style="border-top: none border-right: none border-bottom: none" |
|-
| System Queue Area (SQA)
| style="text-align: center;" rowspan=2 | Fixed area
! style="border-top: none border-right: none border-bottom: none" |
|-
| Nucleus
| style="border-top: none border-right: none border-bottom: none" | Lowest
|}
@Chatul: Below is my attempt which still has external borders. I don't know whether they can be hidden when class="wikitable" is used. Style attributes are separated by semicolons, not spaces. A cell starting with ! is a header cell. I see no reason for that in hidden cells. The three adjacent hidden cells can be combined with rowspan="3". background:white will usually be more like the page background than wikitable cells but it may depend on user settings. PrimeHunter (talk) 02:16, 15 November 2022 (UTC)
Nicely done. The usual method to display code is to just wrap it in <code>...</code> like my first post. Special:ExpandTemplates shows that {{para}} does more but it usually doesn't matter. If the code includes wikitext which would normally be evaluated then also wrap it in <nowiki>...</nowiki> inside <code>...</code> like {{Citation needed|date=November 2022}} (see the wikitext). PrimeHunter (talk) 18:56, 15 November 2022 (UTC)
Sorry, I had assumed that {{para}} and {{code}} (or <code>...</code>) produced distinct metadata.
One last question, given a table like
MVS/XA storage layout after IPL and NIP
Content
Area
Extended AUK, LSQA and SWA
Extended Private
2 GiB
Rxtended User Region
Extended CSA (ECSA)
Extended Common
PLPA/FLPA/MLPA
Extended SQA (ESQA)
Extended Nucleus
16 Mib
Nucleus
Common
System Queue Area (SQA)
PLPA/FLPA/MLPA
Common Storage Area (CSA)
AUK, LSQA and SWA
Private
User region
System region
4 KiB
Prefixed Storage Area (PSA)
Common
o
Is it possible to position the text of a cell using position: relative in order to move 2 GiB up a line and 16 Mib down half a line in a manner that works on desktops, laptops and mobile devices? Or should I leave 16 MiB where it is and use a dummy row to position 2 GiB? --Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:58, 16 November 2022 (UTC)
Removing large gap in text before template
I was looking at Template:United States presidential election results table header just now and noticed that the causes an unattractive gap in an article's text, as if there's an extra line break in the source (e.g.). Is there any way this template can be tweaked to remove the gap? (IMHO, I feel like this template should sit nicely in articles the same way images do.) I tried cleaning up the template myself, but to no avail.--Gen. Quon[Talk]18:14, 15 November 2022 (UTC)
Is it WCAG-friendly to have |scope=col applied to the bottom row, like in this example, or is it better to use |-style="background:#EAECF0; font-weight:bold; text-align:center" in the line preceding it instead? Qwerty284651 (talk) 22:34, 10 December 2022 (UTC)
@Qwerty284651: Repeating the column headers at the bottom of the table doesn't do anything to improve accessibility. If anything, it could cause some confusion for a person listening to a screen reader read the table. It's not a practice I would recommend doing, but most do it for visual purposes only because the table is tall and the top column headers scroll out of view when viewing the bottom of the table. They will sometimes repeat them in the middle of the table too. Jroberson108 (talk) 22:54, 10 December 2022 (UTC)
So, it's best to apply a wikimarkup code, for e.g., |-style="background:#EAECF0; font-weight:bold; text-align:center", that mimics a look of a bolded bottom row like so:
@Qwerty284651: The column headers at the bottom of the table don't define any data under them, so they don't need the scope attribute. In essence, the bottom column headers aren't needed except for visual purposes. Jroberson108 (talk) 02:08, 11 December 2022 (UTC)
@Jroberson108, can the first cell of the bottom row be treated as an indicator of a row and be used with scope="row" since it is a row, or treat it as a regular cell and use a pipe character | instead to not confuse screen reader users? Qwerty284651 (talk) 05:48, 11 December 2022 (UTC)
@Qwerty284651:scope="row" doesn't indicate a row. It is used on a row header that defines the rest of the row's data. Ex. a player's name would be the row header followed by its data (height, wins, losses, etc.), and those row headers would be defined by a column header of "Player". This particular table you linked to doesn't focus on the players, but titles, so those are the row headers; although, the players might be better set as the row headers instead of the number of titles won since they are doing the winning. Basically it is a list of top title winners and the number, locations, and timeframe of their wins. As for the recommendation to "not confuse screen reader users", I would remove the bottom column headers all together. The table isn't that tall to begin with. The table above it is taller and doesn't repeat the column headers. Also consider moving the abbreviations from above the table to the top column headers with Template:Abbr. Jroberson108 (talk) 12:54, 11 December 2022 (UTC)
How do I make the text align to the top of a row?
I'm working on Universal City Zoo#Head trainers and I would like the text in every cell to start at the top left. (I'm going to move the biggest text blocks to their own articles but I'm not there yet.)
What do I add? The top of my table currently looks like this:
{| class="wikitable sortable mw-collapsible"
|-
!Years active at zoo
!Name
!Alternate names
!Other info
|-
Would it be possible to have a page, perhaps called "HELP:TABLE" that explained in English with examples how to have some columns of a table centred, but the first column aligned left, and also how to make a cell span two rows? The help pages are pretty rubbish across Wikipedia, but the Table page seems to have been written by the same people that wrote the manuals for DOS in the 1980s. I just cannot figure out how to align cells - the "align" text just appears in the cell - is it really necessary to specify this for every cell? Meanwhile trying to make a cell span two rows leads to an extra blank column appearing at the end of the table. I presum,e I'm wrongly guessing if the text should go after the "|" (or sometimes "||"). I avoid tables whenever I can, but unfortunately they are sometimes necessary, resulting in much wasted time. Thanks and Happy New Year. Davidelit (Talk)08:04, 2 January 2023 (UTC)
You are right. I moved the text alignment sections together just now. Now they need to be rewritten and clarified. And some more examples are needed. --Timeshifter (talk) 11:36, 2 January 2023 (UTC)
Pixel heights and widths
The text includes a warning: "Setting specific pixel sizes is deprecated... It is strongly preferred to use relative sizes, in percentage or em values." So why do all of the examples use pixels instead of percentages? 22:14, 21 January 2023 (UTC) Furius (talk) 22:14, 21 January 2023 (UTC)
The full statement is: "Setting specific pixel sizes is deprecated, as it interferes with the ability of the browser to adjust content to suit the browser window, device size, user-end font size limits, and other constraints. It is strongly preferred to use relative sizes, in percentage or em values."
The second sentence doesn't make sense. Em values will have similar problems. So will percentages.
It is better to avoid column widths of all kinds, and let the browser window squeeze and narrow the table. At a certain point the table can not be narrowed further depending on the widest word or data in each column.
Percentages will restrict narrowing of some columns.
Better wording might be: ""Setting column widths is discouraged, as it interferes with the ability of the browser to adjust content to suit the browser window, device size, zoom settings, user-end font size choices, and other constraints."
That's a very different thing from the policy as I understand it. It is often necessary to control the relative width of columns / height of rows in a table, which is what all these methods do. Otherwise a single cell with substantial text may cause an entire row/column to be vastly expanded in an unhelpful manner. Pixels and em values assume that the user's window is of a particular pixel/em-width, which is why they are problematic. Percentages simply give relative dimensions, which the browser can then interpret within its own constraints. I don't see how this is a problem.
Anyway, changing the policy would require an RfC. I'm simply saying that the examples which the page gives should match the policy as currently stated. Furius (talk) 13:30, 23 January 2023 (UTC)
It's not a policy. Someone just wrote it up one day, and it has been pretty much ignored since then.
From the top of Help:Table: "It is not one of Wikipedia's policies or guidelines".
Picking one column to use 50% (or any percent) of the available width is going to be problematic as screen width narrows depending on the device.
Anything that prevents the table from narrowing is a problem.
Verbose notes columns are almost always a problem. Because people try to make them wider. Which then messes up the other columns. Notes columns should be avoided. Or the notes column should consist mainly of links to longer notes below the table.