Page MenuHomePhabricator

ResourceLoaderSkinModule: `center` and `small` rules in the `elements` behaviour is not consistent across skins due to inclusion in an optional `elements` feature
Open, LowPublic

Description

Skins using the elements feature ship styles for elements using the small or center class. Presumably these provide replacements for deprecated HTML4 tags. Confusingly, this means the use of these classes is inconsistent across skins.

Following on from @Volker_E comments in T255717#7056266

We would like to move away from classes that define presentation in a world where mobile and accessibility is important and our content can be rendered in different ways.

This will likely touch multiple part of the stack (mostly for use of the small class)
https://codesearch.wmcloud.org/search/?q=class%5C%3D(%22center%22%7C%5B%22%27%5D%5B%5E%22%27%5D*%20center)&i=nope&files=.*%5C.php&excludeFiles=&repos=

including > 1000 user templates:

https://global-search.toolforge.org/?q=class%5C%3D%28%22center%22%7C%5B%22%27%5D%5B%5E%22%27%5D*+center%29&regex=1&namespaces=10&title=
https://global-search.toolforge.org/?q=class%5C%3D%28%22small%22%7C%5B%22%27%5D%5B%5E%22%27%5D*+small%29&regex=1&namespaces=10&title=

If we want to retain support for the class it would be better to apply it to all skins via the module in T279388.

Event Timeline

Small

<small> has been assigned a meaning in HTML 5 and is no longer deprecated. Many of .small's uses might be migrated to use that element on the code side (or perhaps <aside>, which has roughly the same semantic but at a 'block' scope). Review the HTML 5 standard. Consider another element if desired with appropriate styling, of course.

I am not aware of widespread use of that class in wikitext, with some reasonable guess of article-space use at approximately 2k uses (timeout), and just about 100 uses in the template and module spaces. (Most of the other places were noise or discussion or etc.)

Center

So far as I know, .center is used for centering files and thumbnails on the code side. The following wikitext:

[[File:Example.jpg|center]]
[[File:Example.jpg|thumb|center]]

Renders to HTML as:

<div class="center">
  <div class="floatnone">
    ...
  </div>
</div>
<div class="center">
  <div class="thumb tnone">
    ...
  </div>
</div>

See also T78176: Refactor thumbnail styles (drop unsemantic names, and rewrite magnify rules in scope of thumbnails) and T76945: "center" does not center non-thumb image on tablets in Minerva (and other linked tasks) which both have previous associated work and discussion (center used to be part of that ticket but was scoped out at some point?). Accordingly, I am fairly certain it is not for replacement of the <center> element for user-side wikitext since the parser passes the element as-is from wikitext to HTML, and probably not as a replacement any longer for code, though it might have been so somewhere in the MediaWiki < 1.10 days.

It is used widely outside of templates, though possibly feasibly replaced with e.g. Template:Center. On en.wp alone, there are some 10k uses in article space (with timeout). There are some 400 uses in module and template space and another 2k uses besides those figures in the rest.

Besides the mass wikitext use, given its use as a class for image placement, I do not think you can remove it. You will have many angry editors on your hand if you try, the same as with the classes listed in T78176, though that task carries no indication currently of potential uprisings ;). I'm happy to copy this comment about .center over there if desired. (There might be feasibly be renaming, but that's that other task I've seen linked somewhere.)

Jdlrobson renamed this task from ResourceLoaderSkinModule: Drop skin HTML4-compatible classes `center` and `small` rules in the `elements` to ResourceLoaderSkinModule: Drop skin HTML4-compatible classes `center` and `small` rules in the `elements`, applybehaviour consistently across skins.May 6 2021, 7:26 PM
Jdlrobson updated the task description. (Show Details)

If you need my opinion on this (although I still want my task re-opened and actually fixed), I’ll say that the notion of dropping all helping classes is wrong and counterproductive. If a Wikimedia-deployed skin has discrepancies in its appearance for these classes, as Minerva does, this should be fixed instead. Sure, we can even drop .wikitable out of core since you can implement it in TemplateStyles, but does it solve anything? No, the savings are negligible and are not worth the effort. Exactly the same with this. There are contexts where editors want to centre (or right-align, or left-align, in fact) something and will/can not use the necessary templates for it, and that is fine. Moreover, it would be better if they learn to use some set of classes instead of a bunch of inline styles. If thumbnail markup should be implemented any other way, that should be the scope, not dropping the class.

Edit to above: Sorry for not filling myself in with task description changes, I see that you are open to retaining the class, which is good.

Edit to above: Sorry for not filling myself in with task description changes, I see that you are open to retaining the class, which is good.

No worries, I could have made that clearer here. I've renamed the title now.
Main goal here is consistency. The institutional knowledge from editors like yourself is a really important factor .

Jdlrobson renamed this task from ResourceLoaderSkinModule: Drop skin HTML4-compatible classes `center` and `small` rules in the `elements`, applybehaviour consistently across skins to ResourceLoaderSkinModule: `center` and `small` rules in the `elements` behaviour is not consistent across skins due to inclusion in an optional `elements` feature.May 6 2021, 11:50 PM

Change 691050 had a related patch set uploaded (by Nikerabbit; author: Nikerabbit):

[mediawiki/extensions/Translate@master] Sandbox: Swap center class to text-center

https://gerrit.wikimedia.org/r/691050

Change 691050 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Sandbox: Swap center class to text-center

https://gerrit.wikimedia.org/r/691050

Nikerabbit subscribed.

Since Translate is no longer affected, I'm removing the tag to keep our workboard clean.