A request for the ability to center-justify the text in a tables cells/rows/columns.
This is usually done by adding style="text-align: center;" to either the entire table, or rows, or cells.
Main documentation at https://www.mediawiki.org/wiki/Help:Tables#Attributes_on_tables
Description
Details
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Open | None | T103276 Provide a way to align/justify the contents of a table cell | |||
| Open | None | T54180 Be able to set table cell background (and other formatting options) | |||
| Open | None | T176272 Decide on what to recommend for table style usecase | |||
| Resolved | simon04 | T393163 Copy align and text-align and valign and vertical-align when inserting a new row |
Event Timeline
Note that there is a request for the table syntax to make it 'easier' to do column/row alignment of table cells T2418: Easier and better alignment within Wiki Tables (but mostly discussed in T2986). Just to point out that this isn't particularly easy, even in wikicode, so any improvement here would probably be very much appreciated by editors.
Yes, I'd rather VE didn't support and encourage the status-quo of using style attributes.
I don't think arbitrary styling is necessary here? Text alignment is pretty easy to figure out with classes that also convey semantic information e.g. <td class="number">. In English, numbers are generally right aligned; normal text is left aligned, dashes and abbreviations are generally centered. Supporting basic classes for certain kinds of information seems entirely reasonable (if we don't support class provision today in VE?).
The main problem here is there are a many ways to set the alignment of a table cell:
- style attribute
- align attribute
- class attribute
- style attribute on the parent row, table, or other container
- class attribute on the parent row, table, or other container
Even if we decide on the cell level style attribute, the editing interface would have to be aware of all the other factors to correctly show the existing alignment. For example the default alignment of <th> is center due to a CSS rule. Further complicating this is that it could vary by skin (although perhaps we can ignore that edge case).
A simpler version would explain in the interface that we are only able to set and read the alignment by the cell's style attribute, and that this may be in conflict with other inherited styles.
Change 787507 had a related patch set uploaded (by Esanders; author: Esanders):
[VisualEditor/VisualEditor@master] [WIP] Set table cell alignment
Change 787510 had a related patch set uploaded (by Esanders; author: Esanders):
[mediawiki/extensions/VisualEditor@master] [PULL THROUGH] Set table cell alignment
Test wiki created on Patch demo by ESanders (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/adfa52d0c8/w/
Just FYI — EN has a template that allows simple setting of left/centre/right alignment for all cells in specific columns.
See https://en.wikipedia.org/wiki/Template:Table_alignment
{{Table alignment}}
{| class="wikitable defaultcenter col1left col3left col4right col23left"This allows many tables to have no need for styles to be set for individual cells.
Oddly, the CSS classes are defined for 29 columns.
See https://en.wikipedia.org/wiki/Template:Table_alignment/tables.css
The table alignment template works well to align text in individual columns:
https://en.wikipedia.org/wiki/Template:Table_alignment
It doesn't work on a column of row headers though.
It would be nice if the template wasn't needed, and its classes automatically pulled up the necessary CSS from the MediaWiki software instead of from the template styles CSS page. And no template would need to be placed above the table.
I don't know if this is possible. It it were possible, then the CSS wouldn't be loaded for every page, but only for those pages that need it.
Yeah we don't and wont use the col* class system. It totally breaks icw row/col spanning and other complex table structures, which will confuse people even more. If something like this ever gets added, it will probably have to be PER cell.
I'm not following you. The template is currently transcluded 2200 times. I have used it many times. If there is a problem with col/row spans then I don't use it in that particular column. No big deal.
If the CSS came via the class alone (without the template), I don't see how anything would be different. Usage of the classes would remain the same. People would still have to observe the class limitations. This is true for the rest of the table templates and their classes too. They have limitations. They are explained in the documentation of the various table templates. Those explanations would have to be moved to table help pages.
My main question is whether it is possible to call up the class CSS on a per use basis. But without coming from template styles, nor from Common.css. See some other table templates linked from the "See also" section here:
https://en.wikipedia.org/wiki/Template:Table_alignment#See_also
If this were possible, these table classes would be used more often. Possibly a lot more often. Because people wouldn't have to remember the template names too, where to place them, number and type of brackets, etc..