Wikipedia talk:TemplateStyles

Column alignment
I have started a discussion about using a general templatestyles page directly in articles to align a whole column without code in each cell: Village pump (technical). PrimeHunter (talk) 14:59, 13 December 2022 (UTC)

Duplicate styles
This question relates to a RfC at Wikipedia talk:Manual of Style/Tables and a discussion at the Sort under template talk page. One user expressed an interest in having two classes with identical styling for reasons he feels makes the template easier to use. Example:
 * sort-under-center
 * sort-under-right
 * sort-under ["popular choice" with identical styles to sort-under-right]

It's my understanding that only essential styles are added to MediaWiki:Common.css to help keep size and load times minimal, amongst other reasons. Do template styles follow the same practice? Are there any unforeseen problems? Keep in mind that duplicating the styles would add an extra 16 CSS selectors (thus far) to Template:Sort under/styles.css. Jroberson108 (talk) 09:31, 5 February 2024 (UTC)


 * Common.css is a huge file. One of the reasons for TemplateStyles was to lessen the size of Common.css. So the CSS for TemplateStyles would only be pulled as needed.
 * Some additional text for one more class in TemplateStyles is a very small addition. And it is very simple to do. But it greatly increases the ease of use of that template in my opinion. I edit a lot of tables. In fact, I have written large parts of Help:Table and its subpages. People copy what they see done on other tables. So they can copy it without having to wade through template docs, and make class choices.
 * So far, there seems to be consensus for the first 2 classes. 2 editors want class=sort-under in addition. Jroberson108 is opposed.
 * class=sort-under-center
 * class=sort-under-right
 * class=sort-under - with it being the popular choice so far: right.
 * I want to use class=sort-under because it is easiest to remember. If I remember the template name, then I just add a dash and I then have the class name. That is how most of the table templates I use work:
 * And it is easier for less experienced table editors than me. The pattern is obvious. They can just copy the above 2 lines to many other sortable tables without problems. --Timeshifter (talk) 10:03, 5 February 2024 (UTC)
 * WOW, there is no reason to duplicate the RfC here. I kept the question as concise and unbiased as I possibly could for a quick answer to verify the practice is acceptable before returning to RfC. They are capable of clicking on a link to read more. Jroberson108 (talk) 10:16, 5 February 2024 (UTC)
 * I didn't think your post was clear or specific enough. And the other discussion is focused on multiple questions, not just this one. --Timeshifter (talk) 10:20, 5 February 2024 (UTC)
 * I didn't think your post was clear or specific enough. And the other discussion is focused on multiple questions, not just this one. --Timeshifter (talk) 10:20, 5 February 2024 (UTC)

Template scripts
or anyone else. I'm not seeing much documentation on template scripts, so I'm asking here. Can a script be added to the sticky header template for  to move header rows into the  element? I understand the need to avoid malicious code, but if it were managed similar to gadgets by someone with higher permissions, then I would think it's possible. Ideally, MediaWiki would just do this to all tables (not just sortable) making this script and the same move done in the sticky gadget obsolete. Jroberson108 (talk) 21:21, 16 February 2024 (UTC)
 * This is not possible right now, but it may be possible soon with On-demand gadgets. * Pppery * it has begun... 22:08, 16 February 2024 (UTC)
 * Thanks for the quick response. Seems like it would work once available. The "no-JS fallback" for sticky header would simply be nothing sticky, similar to sortable tables not being sortable. Static row numbers would also benefit from the same move, but its "no-JS" version would be problematic. MediaWiki moving the rows without JS would be the best solution. Jroberson108 (talk) 23:04, 16 February 2024 (UTC)

RfC: converting sitewide CSS to TemplateStyles
Should TemplateStyles be officially preferred (where possible) to sitewide CSS for non-sitewide styling ? 15:30, 21 February 2024 (UTC)

Notified: Village pump (idea lab), MediaWiki talk:Common.css, Village pump (technical). House Blaster  (talk · he/him) 15:30, 21 February 2024 (UTC)


 * Support as proposer, for all the reasons outlined in MediaWiki talk:Common.css/to do. In particular, it allows more people to edit "sitewide" CSS (WP:5P3) and allows for faster load times. If successful, this would greenlight this stalled bot request and other related work. House Blaster  (talk · he/him) 15:30, 21 February 2024 (UTC)
 * I don't see how this RFC would do anything to un-stall that BRFA. The questions there are far more specific than "is TemplateStyles good?". Anomie⚔ 17:27, 21 February 2024 (UTC)
 * My read of the discussion is that it was stalled (well, besides the fact that the bot operator went inactive) because it was the first time a bot is "implementing" TemplateStyles this way places this BRFA as a precedent and puts an even larger onus on BAG to establish a clear consensus for the task. I think this discussion would clearly resolve that concern. House Blaster  (talk · he/him) 17:42, 21 February 2024 (UTC)
 * I agree with Anomie here, the issue is more specific. This particular issue is: there are 100k pages using a class in a table "ad hoc" and we don't have anything currently in TemplateStyles that does similar on that many pages, and there's been at least some discussion prior that we could have issues down the road (which I think are negligible - the fix would be "re-add the CSS to Common.css"). There is clear consensus that moving stuff from global CSS to TemplateStyles is beneficial, otherwise the quantity of CSS already removed from MediaWiki:Common.css would be in violation of that implicit but otherwise clear consensus.
 * Suggest removing the RFC tag for now and just getting all the types of editors on this page discussing the actual problem. Izno (talk) 17:47, 21 February 2024 (UTC)
 * Happy to remove the RfC tag. House Blaster  (talk · he/him) 18:13, 21 February 2024 (UTC)
 * I'm not buying the argument that the community can't get edits made. First, any of these pages that are massively used are going to end up admin-protected anyway - and most admins aren't going to try to touch a SCSS page. Also, Category:Wikipedia interface-protected edit requests is rarely backlogged. — xaosflux  Talk 15:47, 21 February 2024 (UTC)
 * FWIW there's been a rather consistent trend of moving common->ts already has been a key champion of this trend. Not sure there really is a problem to solve right now? For example, there is pretty much no chance we'd add any new template specific styling to sitewide scripts these days. —  xaosflux  Talk 18:18, 21 February 2024 (UTC)
 * @Xaosflux Indeed. Take a look at what the BRFA linked by House wanted to do and then feel free to give an opinion on that. Izno (talk) 18:42, 21 February 2024 (UTC)
 * For clarification, would officially preferred mean that - where possible - style rules in sitewide CSS should be moved to the TemplateStyles of the relevant templates? Only asking as it occurred to me that it could potentially also refer to changing the content model of all sitewide CSS files to TemplateStyles/moving all sitewide CSS rules to a fully-protected TemplateStyles page. (It might just be me who's confusing themselves with the wording, though!) All the best, &zwj;—&zwj;a smart kitten[ meow] 17:18, 21 February 2024 (UTC)
 * it is meant to mean something like "when things are meant to display on every page, they should be in the sitewide style. If it is not something for the entire site and can feasibly be done by a template/with TemplateStyles, it should." I have amended the question for clarity (by adding the words for non-sitewide styling). House Blaster  (talk · he/him) 17:27, 21 February 2024 (UTC)
 * The question is too broad. Generally, TemplateStyles should be preferred; however, the developers have documentated certain cases where TemplateStyles current functionality should not be relied upon. Styles included by a template can currently affect content on the page outside of the content generated by that template, but this ability may be removed in the future and should not be relied upon. We should not make use of such functionality so as to not end up in a position where another migration would be needed if said functionality is removed, which would prohibit uses like the one proposed in Bots/Requests for approval/William Avery Bot 5. —&thinsp;JJMC89&thinsp; (T·C) 04:36, 22 February 2024 (UTC)
 * Yes, and as I've said already, I think both 1) their warning is bunkum (a different WMF engineer said this use is kosher!), and 2) the fix on our part is trivial (in two different ways, the first is putting templatestyles tags directly in article wikitext and the second is just putting the CSS back in Common.css if it's necessary), and 3) we already have other templates (like the one literally 2 sections above) doing the exact same thing. Izno (talk) 05:24, 22 February 2024 (UTC)