Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are all uses of the title attribute discouraged? #10875

Open
ddbeck opened this issue Dec 19, 2024 · 3 comments
Open

Are all uses of the title attribute discouraged? #10875

ddbeck opened this issue Dec 19, 2024 · 3 comments

Comments

@ddbeck
Copy link

ddbeck commented Dec 19, 2024

What is the issue with the HTML Standard?

The title attribute section contains this note:

Relying on the title attribute is currently discouraged as many user agents do not expose the attribute in an accessible manner as required by this specification (e.g., requiring a pointing device such as a mouse to cause a tooltip to appear, which excludes keyboard-only users and touch-only users, such as anyone with a modern phone or tablet).

(It also appears a few other places, such as the requirements for providing text alternatives section.)

Do the editors wish to discourage authors from all uses of the title attribute?

As someone working on documentation for the web platform, I don't know how to describe the condition of this feature. Unlike other features in this and other web platform specifications, it's unclear if the title attribute is under the umbrella of things that the spec wishes for authors to not use in new web content.

There's an additional layer of uncertainty here, given by "currently." I took this to mean the note was anticipating changes, except it's 12 years old (commit). I couldn't find any open issues discussing the title attribute.

It'd be helpful if the spec could be rather more specific in this note, both with respect to when the note applies and to whom. I don't have an opinion about what the actual position of the editors ought to be, but I'd like to know what it is.

To resolve this, I'd expect the note to say something along the lines of "Authors should not use the title attribute because…. Authors should instead…" or "Authors should not use the title attribute unless…" depending on what y'all think the answer is. Or if it's really serious, to list title amongst the obsolete features.

For background, this came came up while trying to summarize feature information for developers in the web-features project: web-platform-dx/web-features#2461.

This is my first time filing an issue with WHATWG, so please let me know if I've missed anything. And thank you for considering this issue.

@annevk
Copy link
Member

annevk commented Dec 19, 2024

I think the note is accurate? As in, it seems fine to use it if the information is otherwise available or not that important, but you cannot rely on the end user having access to it. The most commonly used device to access the web does generally not expose title attributes on arbitrary elements, for instance.

@valtlai
Copy link

valtlai commented Dec 20, 2024

I think there are some valid use cases for the title attribute:

  • A label for an RSS/Atom/JSON feed, especially if there are several of them:

    <link
      rel="alternate"
      href="/blog.rss"
      type="application/rss+xml"
      title="Blog RSS feed"
    >

    This one also applies to alternative style sheets.

  • An accessible name for an <iframe> element:

    <iframe
      src="demo.html"
      title="Demo: HTML popover"
    >
  • A custom validation message for a form element:

    <input
      pattern="[0-9a-z]{40}"
      title="Use full SHA-1 commit hash"
    >

@captainbrosset
Copy link

What about adding this then:

"Relying on the title attribute to provide additional information about an element via a user-agent tooltip is currently discouraged as many user agents do not expose the attribute in an accessible manner as required by this specification".

This would make the note clearer to me. Reading this, I know when the title attribute is discouraged, and when it isn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants