[proposal] list head/caption/title


#21

In terms of ARIA, would it be useful to have a generic caption role for stuff like figcaption, lt, and caption?


#22

I do not necessarily oppose the <figcaption> proposal, but I think that it is not widely liked or used. I am also curious to know how AT users interact with it. Like @Michiel said, a generic <caption> might be more useful. The definition provided at https://www.w3.org/TR/html51/grouping-content.html#the-figure-element indicates that “The figure element represents some flow content, optionally with a caption, that is self-contained (like a complete sentence) and is typically referenced as a single unit from the main flow of the document.” Are lists self-contained? I think that only close readers of the spec realize that these can be used for objects other than figures/images. It also makes me wonder why the <caption> element exists for tables, when the <figcaption> element seems more appropriate.


#23

The FIGURE and FIGCAPTION elements have been added to the HTML spec much later (in HTML5+) than the TABLE and CAPTION elements.

Fwiw, originally, the CAPTION element has been planned to be used as FIGURE caption, but later it has been replaced with FIGCAPTION based on (in)compatibility with existing implementations that unfortunately completely ignore CAPTION elements outside tables, effectively treating CAPTION element as its content, so non-table CAPTION elements are not reflected in DOM at all which is still truth even in today’s browsers.


#24

@SteveF I like your proposal. The only thing I would change, and I realise it borders very closely on bikeshedding, is the name. To motivate that:

  • Note that li, dt, and dd auto-close whereas lt does not (and cannot without a much more annoying change). In order to manage expectations of users of shorthand markup (even if they are few) I think it would be better if the element were more visually distinct in code.
  • More importantly, lt and li are awfully close visually, especially in certain fonts (and in caps: LT/LI). I think this could be a source of confusion.

As a result I’d suggest listcaption, if only because it occupies somewhat the same space as figcaption.


#25
  • I understand and respect that some choose to not to use section element to format their documents for some reason. But since that’s not HTML’s problem, HTML should not be blamed for. Even when section element is not present (like the original example), heading elements <hx> already imply sectioning. So the list in the example does belong to a section no matter section element is present or not.
  • IMHO, a list head is not needed in this case. The list belongs to a section (no matter section element is present or not) and heading element <hx> is enough for the purpose.

#26

I’m very well aware. My first point was that in your proposed markup all sections/headings were at the same level, whereas they are nested in the original use case. But it’s a side point not particularly relevant to the list head topic.

[quote=“IanY, post:25, topic:1832”] IMHO, a list head is not needed in this case. The list belongs to a section[/quote]

No, precisely not. The use case is: how to model a list head (or “caption”, which appears to better represent the idea) without requiring the list to be in its own section.


#27

I was aware that those heading elements (<h1>-<h4>) aren’t the same, and was considering pointing that out. But I ended up focusing on the list.

Not sure how you came up with that conclusion, but I fail to see the use case is meant to model a list head/caption without requiring it to be in its own section. The HTML code provided by the OP already implies that the list is inside a section.


#28

The proposal illustrated one method currently available in the absence of a list title, but it is clear that this is not the semantics that are wanted. Suggest you read the note linked in the proposal:

It is tempting to use HTML5 h1 – h6 elements or add role=“heading”, but in both cases the result is unwanted default navigation.


#29

Thanks. But the list illustrated in that hyperlink is missing its context so we have no clear clue where it is used at.

If the list is used in an article, it surely has its context (ex: paragraphs) stating its purpose. In that case, wouldn’t adding a list head be redundant?


#30

@SteveF and @rdeltour interpreted my intent and the intent of the note correctly. The goal is to introduce a an element that captions a list without introducing sectioning or navigation to the DOM.

Please clarify this point. <p> conveys very little semantic meaning. Other than that, we have mostly been relying on reading comprehension skills, which most machines lack.


#31

I see. However, we still need use cases for determining if such a new element is necessary.

Sure. Let me use an article which talks about noble gas as an example. I’m not a copywriter so I’m unable to compose a decent article. Therefore I borrowed some text from a Wikipedia article. So if the list illustrated in the note is in an article, the article might look like:

Noble gas

The noble gases make a group of chemical elements with similar properties; under standard conditions, they are all odorless, colorless, monatomic gases with very low chemical reactivity. The six noble gases that occur naturally are:

  • Helium
  • Neon
  • Argon
  • Krypton
  • Xenon
  • Radon

Ununoctium is predicted to be a noble gas as well, but its chemistry has not yet been investigated.

For the first six periods of the periodic table, the noble gases are exactly the members of group 18 of the periodic table. Noble gases are typically highly unreactive except when under particular extreme conditions.

(the article goes on) …

As we can see, in the article above, the purpose of the list is already described by the last sentence of the first paragraph. In that case, adding a list head would be redundant.


#32

Here’s an example from a random journal article saved on my laptop. I have set the list title as h2 for illustrative purposes. :

Potential risk factors for multiple sclerosis



  • Female gender
  • Caucasian race
  • Genetic
  • HLA DR15/DQ6, IL2RA and IL7RA alleles
  • Infections
  • Epstein–Barr virus (EBV) infection
  • Temperate climate
  • Low vitamin D level
  • Lack of sunlight exposure
  • Cigarette smoking

#33

@TzviyaSiegman Could you show us the hyperlink of the journal article so that we could evaluate the context of the list?


#34

Could we reuse <label>? I haven’t found it to break the parsing model yet inside lists, and frankly HTML really could use a generic labeling/captioning element for future additions, etc.


#35

I doubt it. Part of the semantics of label is related to the way that it gets into the focus order - and then messes with that in interesting and sometimes unpredictable ways.

Given that is a key reason for it to exist, but one that would interact weirdly with lists, I think it’s the wrong one.

And alternative to look at would be the legend element, currently for fieldsets, but I haven’t even done a napkin test, and that could well be a bad idea for some reason that is pretty readily apparent.


#36

Good point about the focusing. <legend>, <dd>, and <caption> were all originally considered for <figcaption>'s place, but they all had parsing issues, so it can’t be one of those.

All I can think of is <name>, but that’s almost too generic.


#37

I believe exact tag name is a much less important thing compared with semantics.

We could, for example, easily introduce a new element like gcaption or gc (Global Caption, Generic Caption) or gtitle or gt (Generic Title).


#38

@TzviyaSiegman @robin is there interest in developing this proposal further?


#39

I’m certainly interested in seeing it come true, unfortunately I don’t have the bandwidth to drive this effort or write up a spec. @TzviyaSiegman just had a baby (:smiley_cat:!) so it would be worth waiting a little bit in case she doesn’t answer right away.


#40

IMHO, the introduction of a new element needs to be supported by a certain amount of use cases. And as discussed above, we still haven’t seen an use case which really shows the necessity of such a new element.

A list isn’t likely to just exist on its own purposelessly in a document; its existence surely is accompanied by some context that can explain its purpose. In such a case, a list heading is redundant.

If some of you really want list heading so eagerly, I personally would suggest resorting to CSS generated content instead. For example:

<ul id="ng">
    <li>Helium</li>
    <li>Neon</li>
    <li>Argon</li>
    <li>Krypton</li>
    <li>Xenon</li>
    <li>Radon</li>
</ul>
#ng::before {
    content: "Noble gases";
    display: block;
    font-weight: 700;
    font-size: 1.35em;
}

This approach of relying on CSS generated content for semantics is inspired by @SteveF, who is a supporter of the said approach. Although I personally disagree with the said approach, it’s still better than seeing a redundant element (imo) being introduced into HTML.