Should we omit title attributes from xref macro output?

Over in the “short descriptions” work, Chris comments:

I did have a point about title attributes being included with full summaries of properties linked to. They are shown to be problematic for accessibility in many ways, see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title#Accessibility_concerns. Do we need to include them?

(https://github.com/mdn/data/issues/261#issuecomment-416480994)

If we think this about short descriptions, should we also omit them from the output of the various xref macros? (e.g. https://github.com/mdn/kumascript/blob/master/macros/cssxref.ejs#L86)

So, this is being done because most browsers use the title attribute’s value to generate a tooltip, which is a handy feature. It is often enough to just hover over something and read the tooltip to get an idea what a method or whatever is about.

1 Like

Yes, I’m aware of that. The point of the articles linked to in Chris’s comment, in particular https://inclusive-components.design/tooltips-toggletips/, was that using title for tooltips is bad for accessibility.

Hence the question: if it’s a bad enough thing that we don’t want to do it for the short descriptions we expose in mdn/data, should we still do it for MDN itself?

I personally think we shouldn’t. If you are exploring a topic, and come across a property of interface name where you have no idea what it does, you can always follow the link to find out more. In many cases, the tooltips are too long to be easily digestible.

But I can understand the convenience factor; does it outweigh the a11y problems?

1 Like

I don’t think so, and I believe that the xRef case is providing auxiliary descriptions.

The linked article doesn’t say that the title attribute is always bad for accessibility, but that you should consider providing an accessible alternative if you decide to use them and to avoid using them for primary labels.

In the xRef case, the primary label is the textContent of the <a>nchor link, and the title attribute provides an auxiliary description, which is copied from the first paragraph or the article’s seoSummary.

I think the better solution here is to fix our summaries so that they are not excessively long. Or find another mechanism by which to add tooltips; ideally one which can be disabled by users that do not want them. But I think they offer enormous value. They save me an enormous number of clicks when reading documentation.

1 Like