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

-

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

FileSize
120.95 KB
120.26 KB

With regular caption styling:
table-caption-now.png

With an H3 instead:
table-caption-h3.png

sun’s picture

I'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.

dead_arm’s picture

The 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.

sun’s picture

Yes, 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:

When a table element is the only content in a figure element other than the figcaption, the caption element should be omitted in favor of the figcaption.

CSS complements this interpretation with the caption-side property, which can receive the values top or bottom. 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 and right.

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.

dead_arm’s picture

FileSize
1.48 KB

In 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.

dead_arm’s picture

Status: Active » Needs review
sun’s picture

Title: Give table <caption> the visual importance of a heading » Add sane default styles for table <caption>

Yes, 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.

dead_arm’s picture

FileSize
1.45 KB

Bartik doesn't have other caption styles, so leaving that out of Bartik, and removing font-weight from system.theme.css.

Status: Needs review » Needs work

The last submitted patch, drupal-1817996-8.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community

Thanks!

That test failure is a random test failure and completely irrelevant here, since this patch only touches CSS.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

danillonunes’s picture

Issue summary: View changes

Actually showing the caption tag :)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Who needs preview, eh?