Page MenuHomePhabricator

Make it possible to set vertical text alignment for a table in VisualEditor
Open, LowPublic8 Estimated Story Points

Description

Let's make it possible to set the vertical alignment for an entire cell in one or two clicks.

From @GOIII at T54180#2000975:

One of the most common "deviations" made to table element defaults is changing the vertical-align of all (or nearly all) of the table cells in a table to render top rather than default middle.

Most folks assume this requires changing the default vertical-align value per every TR or per each TD within a table but the default is actually ''inherit'' for these elements - set by tbody, thead or tfoot which actually has the vertical-align:middle setting.

Understanding the tbody element is not 'shown but always present' we can still simplify the table rendering of cell content throughout an entire table by making a simple .css addition to the default stylesheets such as...

.valign-td-top > tbody {
vertical-align: top;
}
... in turn, setting table class="valign-td-top" is all the user needs to add (either manually or by design in a VE table option) to accomplish top rendering of content.

Worst case scenario is the user needs to [re]adjust the TH header row's vertical-alignment back to middle - far less work than applying inline styling to each TR or every TD as is the case now.

Event Timeline

I opposed a similar request at en.wp Common.css for a generic "top align all the things!" class. Why are people setting top alignment? We should have semantic class names so that, across the board we know why we are getting some set of functionality. ("That's just how they do" isn't all that great an answer.)

Not to fork the request, but I can tell you that text alignment is a lot easier to think up a use case or two for (namely, numbers are right aligned; normal text is left aligned, dashes and abbreviations are generally centered). (I might go add that to T103276.)

Top alignment makes sense when you have text of uneven but longer sizes, and you want everything to start at the top of the box. Difficulty with finding the first word when supposedly side-by-side paragraphs aren't lined up is a pretty significant usability problem, especially for people with dyslexia and related difficulties, which can make it hard to keep your place on a page.

Look at the large table at https://en.wikipedia.org/wiki/Standardized_test#Score It would probably make sense for all of those "Student #1" and "Teacher #1" lines to start at the same place in the row, instead of some starting at the top of the cell and some starting in other places.

Look at the table at https://en.wikipedia.org/wiki/Wikipedia:Requests_for_comment/Example_formatting#Pro_and_con Now imagine what it would look like if you had one cell filled with a lengthy statement, and the other cell contained only a few words – centered vertically, as if for extra emphasis.

For that matter, look at https://en.wikipedia.org/wiki/Help:Table#Vertical_alignment_in_cells and the example it describes as producing "odd-looking layouts".

The appearance discussed here can already be supplied by adding a lot of HTML formatting code in the wikitext mode. The point of this task is that it would probably be more sensible to have VisualEditor able to cope with a whole-table formatting request, and thus add one line of formatting information. The alternative is dumping a much larger amount of HTML into the wikitext. If you think that experienced editors would actually prefer to see a lot of repetitive HTML formatting codes, rather than a single line per table, then please say so.

Top alignment makes sense when you have text of uneven but longer sizes, and you want everything to start at the top of the box. Difficulty with finding the first word when supposedly side-by-side paragraphs aren't lined up is a pretty significant usability problem, especially for people with dyslexia and related difficulties, which can make it hard to keep your place on a page.

These sound like reasons to make (wikitable) tables vertical aligned top by default. Why is the solution support in VE rather than that much easier choice? (I have a thought, but I figure, might as well ask the proponent.)

Look at the large table at https://en.wikipedia.org/wiki/Standardized_test#Score It would probably make sense for all of those "Student #1" and "Teacher #1" lines to start at the same place in the row, instead of some starting at the top of the cell and some starting in other places.

This table isn't very accessible in that it is being used for notional layout rather than structured as the data table it probably could be (also an accessibility concern). I'm not very sure we should encourage un-semantic behaviors.

Look at the table at https://en.wikipedia.org/wiki/Wikipedia:Requests_for_comment/Example_formatting#Pro_and_con Now imagine what it would look like if you had one cell filled with a lengthy statement, and the other cell contained only a few words – centered vertically, as if for extra emphasis.

Ditto the previous.

For that matter, look at https://en.wikipedia.org/wiki/Help:Table#Vertical_alignment_in_cells and the example it describes as producing "odd-looking layouts".

And ditto the previous.

The point of this task is that it would probably be more sensible to have VisualEditor able to cope with a whole-table formatting request, and thus add one line of formatting information.

That was obvious, thank you.

The alternative is dumping a much larger amount of HTML into the wikitext.

A style attribute with associated styling per row is "much larger"? No, I don't think so.

If you think that experienced editors would actually prefer to see a lot of repetitive HTML formatting codes, rather than a single line per table, then please say so.

Please don't set up a strawman. I did not ask about formatting, I asked about when, where, and why, which you provided beforehand.

Yes, once per row is indeed "much larger" than once per table, in all instances beyond single-row tables. It's my experience that English Wikipedians, at least, would generally prefer to see a single line of code at the top of the table than 25 copies of that code, one per each of the 25 rows in a table. I assume that this is your experience as well.

I believe we have now successfully identified all of the alternatives for this kind of formatting: one change per wiki, one change per table, one change per row, and one change per cell. It is my belief that "one change per table" will be the least disruptive and therefore the most acceptable (to enwiki; not all wikis have the same view). What is your belief?

Deskana set the point value for this task to 8.
Deskana subscribed.

Makes sense, but cannot be prioritised right now.