Wikidata
[edit]Hi. I've connected the template to the Wikidata. IKhitron (talk) 12:20, 14 December 2022 (UTC)
Is it possible to adapt this template to account for rowspans and/or overriding cell alignments?
[edit]@WOSlinker: I love this template, but I've run into an issue where the use of rowspans makes it malfunction, aligning the cells not by their column, but by their relative position in the row. I notice that the alignment issues go away when the table has been sorted. I understand if this is a permanent limitation, but if so, can this template be changed so that individual cell alignments can be overridden (like on the bottom right cell that should be left-aligned)?
| A | B | C |
|---|---|---|
| A | B | C |
| B | C | |
| B | C |
Star Garnet (talk) 10:02, 12 June 2023 (UTC)
- Yes you have to directly override them with inline styling. (Do not use the align attribute, it is deprecated html)
| A | B | C |
|---|---|---|
| A | B | C |
| B | C | |
| B | C |
BTW. It clears up after sorting, because sorting ALSO cannot handle rowspans, so when you first use that, it clones the cells and removes the rowspan. —TheDJ (talk • contribs) 10:59, 12 June 2023 (UTC)
- Thanks! I should have realized the template was simply rendering the deprecated form null. Star Garnet (talk) 18:40, 12 June 2023 (UTC)
- A year later. @Star Garnet, sorry I'm answering just now, but it's the first time I saw you question. Actually, there is a way to fix this problem, without editing each cell. Not in all cases, but in a huge lot of cases, including your example. For some reason this template css sheet includes only the half of the code, I don't know why, but the negative part is missing. I am not going to edit it, because I'm not one of the enwiki tech support, but maybe somebody else can. The relevant code can be found in interwiki links, searching "nth-last-child". IKhitron (talk) 17:34, 2 June 2024 (UTC)
- @IKhitron: Feel free to try to fix this problem. Use the sandbox and testcases pages linked at the top of template page. --Timeshifter (talk) 08:25, 13 August 2025 (UTC)
- I do not know, @Timeshifter, what red type should I do in enwiki to expand template drastically. IKhitron (talk) 19:54, 14 August 2025 (UTC)
- @IKhitron: The change has already been made to accommodate this per #Classes with nth-last-child selector. It's described in the doc too. Jroberson108 (talk) 23:44, 14 August 2025 (UTC)
- Great, thanks. IKhitron (talk) 23:48, 14 August 2025 (UTC)
- @IKhitron: The change has already been made to accommodate this per #Classes with nth-last-child selector. It's described in the doc too. Jroberson108 (talk) 23:44, 14 August 2025 (UTC)
- I do not know, @Timeshifter, what red type should I do in enwiki to expand template drastically. IKhitron (talk) 19:54, 14 August 2025 (UTC)
- @IKhitron: Feel free to try to fix this problem. Use the sandbox and testcases pages linked at the top of template page. --Timeshifter (talk) 08:25, 13 August 2025 (UTC)
Why can't this functionality be merged into the Wikitable class itself?
[edit]Why can't this functionality be merged into the Wikitable class itself? Jorge Stolfi (talk) 13:16, 4 September 2023 (UTC)
Tables with 99 columns
[edit]Adding columns up to 99 to the styles in this edit seems excessive. The highest used is 25 at List of largest airlines in Europe. I would be concerned if any table had 99 columns. Jroberson108 (talk) 14:21, 1 June 2024 (UTC)
- I think you would be safe to go back to 30 for now and it can be expanded later if needed. -- WOSlinker (talk) 16:59, 1 June 2024 (UTC)
- I agree. Reverted it back to 29 columns. It can be increased as needed. Jroberson108 (talk) 19:00, 1 June 2024 (UTC)
Classes with nth-last-child selector
[edit]Adding classes with nth-last-child selector would allow to avoid some limitations on tables using rowspan or colspan mentioned in the doc. rowspan more common in the first column (or first n columns) and if the rest of a table doesn't have rowspan or colspan then all other columns can be aligned by these classes without problems.
Up to 10 classes for each alignment named something like colLast1(left/center/right) through colLast10(left/center/right) would probably be enough (based on a wild unscientific guess).
There are some other minor benefits but this section already in tl;dr territory. Sport1wiki (talk) 23:45, 21 December 2024 (UTC)
- I'm considering to implement exactly that myself if there's no comments/arguments against it.
- I'm also kind of horrified the css apply to basically every
<td>element without any further specific selectors. ArdWar 🖂 07:30, 13 August 2025 (UTC)
Can a template be made to align a row header column to the left?
[edit]See this version of John Wick#Cast and characters:
See diff showing many of the individual cell changes to get the row header column aligned to the left. I used find and replace inside the wiki-editor. I had to do some individual adjustments too (removing the style from various cells). Way too much work.
The overall table alignment style=text-align:left does not effect the row header column.
There has to be an easier way. Maybe a template just for aligning a row header column to the left. --Timeshifter (talk) 22:57, 20 March 2025 (UTC)
- @Timeshifter: The doc says wikitable headers are centered unless individually adjusted. Even if it were possible, you need a way to distinguish column and row headers like setting scope so both aren't styled, which that table and most don't do. Jroberson108 (talk) 23:27, 20 March 2025 (UTC)
- @Jroberson108: OK. I wrote up a how-to section for row headers in the doc: Template:Table alignment/doc. It does not use the template.
- --Timeshifter (talk) 01:50, 21 March 2025 (UTC)
Template affects all tables on page regardless of position
[edit]See diff. JohnFromPinckney: Can you give some examples? Also calling in Jroberson108. --Timeshifter (talk) 07:02, 4 September 2025 (UTC)
- Examples of what? Edit a page with an example table (as from the doc page) but put the
{{Table alignment}}template after the table, then preview. I believe you'll see the same results. Or perhaps I've misunderstood your question. — JohnFromPinckney (talk / edits) 07:18, 4 September 2025 (UTC)- Please provide some examples here, or in a version elsewhere, or best of all, in a sandbox. We need to see exactly what you are talking about. Are the classes being applied to tables other than the one intended? Or are you saying that one can place {{Table alignment}} anywhere on a page just once, and then all tables on the page can individually add classes for it. --Timeshifter (talk) 07:36, 4 September 2025 (UTC)
- See User:JohnFromPinckney/sandboxTS. — JohnFromPinckney (talk / edits) 07:54, 4 September 2025 (UTC)
- Thanks. I see what you mean now. Feel free to clarify that further on the doc page. --Timeshifter (talk) 08:47, 4 September 2025 (UTC)
- @JohnFromPinckney and Timeshifter: I think specifying
"The
is not needed and confuses things. Normally, you just add these style includes above each table that uses it. Even though you could add it once at the top or bottom of an article, as I recall, previewing a section that uses its classes but has the include outside that section will not style it until published, creating further confusion. Best to keep it simple. Jroberson108 (talk) 11:39, 4 September 2025 (UTC){{Table alignment}}template works by including additional CSS and affects all tables on the page (even those positioned before{{Table alignment}})."
- @JohnFromPinckney and Timeshifter: I think specifying
- Thanks. I see what you mean now. Feel free to clarify that further on the doc page. --Timeshifter (talk) 08:47, 4 September 2025 (UTC)
- See User:JohnFromPinckney/sandboxTS. — JohnFromPinckney (talk / edits) 07:54, 4 September 2025 (UTC)
- Please provide some examples here, or in a version elsewhere, or best of all, in a sandbox. We need to see exactly what you are talking about. Are the classes being applied to tables other than the one intended? Or are you saying that one can place {{Table alignment}} anywhere on a page just once, and then all tables on the page can individually add classes for it. --Timeshifter (talk) 07:36, 4 September 2025 (UTC)
Thanks for mentioning that. I had forgotten. I remember being baffled as to why stuff wasn't showing up in previews. I think this deserves explanation. I will try later, if someone doesn't explain it clearly. --Timeshifter (talk) 12:08, 4 September 2025 (UTC)
- I added info to the "Limitations" section of the doc: "Preview will not work unless
{{table alignment}}is in that section. But if it is placed anywhere on the page, then table alignment will occur upon publishing. So to avoid bafflement and confusion by editors previewing sections, put it directly above each table its classes are used in." --Timeshifter (talk) 09:14, 8 September 2025 (UTC)- @Timeshifter: It's not a limitation of this template, but just how Wikipedia calls templates, which should be at or near its usage. See Help:Template#General, which I clarified for these kinds of templates. This template's instructions to
"Place
is correct and sufficient. Jroberson108 (talk) 16:44, 8 September 2025 (UTC){{Table alignment}}above the table"- It's still a limitation. Just one that is common to table templates. I clarified it by adding: "This is true for any table template using TemplateStyles."
- People aren't going to go to Help:Template#General to find out why preview isn't working for a table class they see in the table wikitext. If they don't give up altogether, they will probably go to the template documentation first.
- I agree that this is all that is necessary in the usage section: "Place
{{Table alignment}}above the table and then add some classes to the table." - --Timeshifter (talk) 20:39, 8 September 2025 (UTC)
- @Timeshifter: It's not a limitation of this template, but just how Wikipedia calls templates, which should be at or near its usage. See Help:Template#General, which I clarified for these kinds of templates. This template's instructions to
Hover
[edit]Hi. I'm not sure it's a right template for this, but can you please add the code .hover tr:hover {background-color: #ffff99;}? It is pretty useful for wider tables, to see the exact line all the way. Thank you IKhitron (talk) 06:23, 11 September 2025 (UTC)
- @IKhitron: See Template:Row hover highlight. Jroberson108 (talk) 06:42, 11 September 2025 (UTC)
- Thank you. IKhitron (talk) 06:43, 11 September 2025 (UTC)
Table vertical alignment template merge
[edit]@Sapphaline: and others: Any reason we shouldn't merge the new {{Table vertical alignment}} template into this one? Jroberson108 (talk) 23:33, 28 December 2025 (UTC)
Also, "vertical-align-top" is the only class I can find used. I can think of use cases to make the entire table align top, but not so much a single column. Can't think of any for aligning bottom the full table or a single column. Might be better to copy over what is actually used and add as requested, namely "vertical-align-top" and "defaulttop", where the second class would be on the doc. Jroberson108 (talk) 23:51, 28 December 2025 (UTC)
- @Jroberson108 and Sapphaline: I don't think these templates should be merged. I added the {{highuse}} template to this version of the vertical template documentation. So we can see the latest number of transclusions quickly:
- https://linkcount.toolforge.org/?project=en.wikipedia.org&page=Template%3ATable+vertical+alignment#transclusions
- If they were merged I would want all options kept. Shouldn't have to get a programmer to add options later on. Few people will want to go through a request, and discussion, to add the option back.
- I think adding any amount of vertical alignment options to this horizontal alignment template would just confuse people. I say keep them completely separate. --Timeshifter (talk) 05:29, 29 December 2025 (UTC)
- "Any reason we shouldn't merge the new {{Table vertical alignment}} template into this one?" - we shouldn't because they exist for different purposes ({{Table vertical alignment}} is for vertical alignment, {{Table alignment}} is for horizontal alignment). ""vertical-align-top" is the only class I can find used" - it was used by the old and much less versatile Template:Vertical align rows, which is now a redirect to the new template. sapphaline (talk) 09:54, 29 December 2025 (UTC)
- @Sapphaline: Both purposes aren't so different: table alignment, which this template is better named and known for. Yeah, I'm aware of the history, redirect, and newly added column specific vertical alignments. Although "vertical-align-top" and "vertical-align-bottom" were the only options, "top" apparently was the only one used with no further needs according to the lack of discussions since that template's creation in June 2022. Seems far simpler to just keep what is used and merge into one template. If more options are needed for real use cases, then they can be added. If you want to keep them separate, then that's fine. Jroberson108 (talk) 11:02, 29 December 2025 (UTC)