Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In both #1697256: Create a UI for importing new configuration and #1043198: Convert view modes to ConfigEntity, we are building multiple tables on a page that need each need a title.
The modules page and one of those patches currently uses fieldsets, the other patch manually puts in H3 tags.
Proposed resolution
Give the <caption>
tag the "visual importance" of at least an H3.
Remaining tasks
-
User interface changes
Table captions won't be useless
API changes
-
Comment | File | Size | Author |
---|---|---|---|
#8 | drupal-1817996-8.patch | 1.45 KB | dead_arm |
#5 | drupal-1817996-5.patch | 1.48 KB | dead_arm |
#1 | table-caption-now.png | 120.26 KB | tim.plunkett |
#1 | table-caption-h3.png | 120.95 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettWith regular caption styling:
With an H3 instead:
Comment #2
sunI'm not sure whether we aren't abusing the CAPTION element here for something it wasn't intended for.
Technically, the caption is a legend to the table, comparable to a legend for a chart/diagram.
Comment #3
dead_armThe intended purpose of the caption element is to be a table's title.
See the spec https://developer.mozilla.org/en-US/docs/HTML/Element/caption.
Comment #4
sunYes, a table's title. Not a chapter's title.
The HTML5 spec provides a concrete example.
The common usage throughout the web really maps to a legend, not a heading that forms an essential part of the document structure.
Along the very same lines, both MDN and the spec present the same usage note:
CSS complements this interpretation with the
caption-side
property, which can receive the valuestop
orbottom
. We do not want these headings to appear below the table, right?MDN/FF goes even one step further and supports the non-standard property values
left
andright
.I didn't take the time to look up these details previously, but now that I did, this issue clearly won't fix for me.
Comment #5
dead_armIn re-reading this issue, I realize that I was looking at this from two angles. I think there needs to be a separate issue to address the design of the view modes page, in order to style file entity section titles.
For this actual issue, I DO think that the caption tag should be used with tables, I don't think it should be styled as an H3 or used as page section headings that indicate chapters as pointed put in #4. Captions in general, if they are utilized, should have better styling, so they don't show up looking like the first screenshot in #1.
In summary I think we should use the the caption tag for the sake of proper markup, because it is functionally the title of the table, but I think it could just be left-aligned, (right-aligned for RTL) and a new issue will address visually indicating the page sections on a view modes page.
Comment #6
dead_armComment #7
sunYes, that looks more acceptable to me. Adjusting issue title.
However, I don't see why we'd need to declare/override the font-weight? (Also note that style properties must be sorted alphabetically.)
Normalize.css doesn't do that either, so I'm fairly sure that it isn't needed and that Bartik only contains it, because some of its other (own) styles may set a font-weight.
Comment #8
dead_armBartik doesn't have other caption styles, so leaving that out of Bartik, and removing font-weight from system.theme.css.
Comment #10
sunThanks!
That test failure is a random test failure and completely irrelevant here, since this patch only touches CSS.
Comment #11
catchCommitted/pushed to 8.x, thanks!
Comment #11.0
danillonunes CreditAttribution: danillonunes commentedActually showing the caption tag :)
Comment #12.0
(not verified) CreditAttribution: commentedWho needs preview, eh?