question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't display dotted underline on `abbr[title]` tags to browsers that don't support hover

See original GitHub issue

Prerequisites

Proposal

Currently the Abbreviation styles show the dotted underline on all browsers, even mobile devices where it isn’t possible to hover over them to show the title.

I’d like to propose that the styles for abbr and .initialism be limited to only browsers/devices which support the hover:hover media query (namely iOS/iPadOS) by updating reboot.scss. I think it’d look something like this:

@media (hover: none) {
  abbr[title] {
    -webkit-text-decoration: none;
    text-decoration: none;
  }
}

@media (hover: hover) {
  abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
    text-decoration-skip-ink: none;
  }
}

I’ve tested this on desktop Chrome 102, Edge 102 and it works exactly as expected there - the text is not underlined on iPadOS 15, iOS 15 and Android 7 (Chrome 102) where it isn’t possible to see the title - even with a pointing device (mouse) connected.

CodePen: https://codepen.io/coliff/pen/rNJbEoM

I used this to make a simplified page test: https://tests.christianoliff.com/title-style-hover/

Motivation and context

Currently the Abbreviation styles show the dotted underline on mobile devices which don’t support hover and it can be frustrating for users to see the dotted underlines on abbr text but have no way to interact with it. It’d be better if the text just appeared as normal text.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
patrickhlaukecommented, Oct 18, 2022

quickfire: don’t use @media (hover: ...). use @media (any-hover: ...)

https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/

1reaction
julien-deramondcommented, Jun 23, 2022

Yes you’re right, let’s not do it by default. If we still find it useful maybe we could mention this trick only in the documentation as an option or we could create a specific class (utility) for the users to use it only when it’s needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove underlining caused by abbr tag - Stack Overflow
When using <abbr> these words get a dotted underline and on hover cursor changes to one with a question mark.
Read more >
The abbr element | HTML5 Doctor
An <abbr> element does not necessarily need a title attribute, although it never hurts to include it. It depends on a document's content...
Read more >
Making the abbr element work for touchscreen, keyboard, and ...
The <abbr> element isn't able to be brought into focus, e.g. by a keyboard user pressing the tab key. Mobile browsers don't display...
Read more >
<abbr>: The Abbreviation element - HTML - MDN Web Docs
This provides a hint to user agents on how to announce/display the content while informing all users what the abbreviation means. If present, ......
Read more >
Abbreviate Your Code with HTML abbr Tag - Samantha Ming
If you open this page on Safari, there will be no underline. Also, the underline is only present if you have a title...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found