Stop Safari from displaying tooltip when text overflow is set to hide with ellipsis

Is there a way to completely eliminate the default browser tooltip that appears when hovering over truncated text within a link?

The text is being truncated due to the following CSS ellipsis rule:

text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;

After applying these rules to a fixed width div, an HTML tooltip seems to appear (specifically in Safari, not in Firefox or Chrome.)

Check out this jsfiddle link.

I have attempted using JS with preventDefault and adding an empty title attribute, but neither have been successful.

Answer №1

The feature allowing tooltips to display for elements with truncated text and no title attribute is a part of the WebKit core, but it is not enabled by default. Safari is the only browser that overrides this setting and enables the behavior. Unfortunately, there is no way to disable this feature using your application code.

To work around this issue, you can insert an empty block element inside the element that has the overflow hidden with text-overflow: ellipsis. This can be implemented as shown in @bas's answer or by creating a pseudo-element with CSS:

&::after {
  content: '';
  display: block;
}

(using SCSS syntax). If you are using Sass, you can create a mixin that handles hiding text overflow with ellipsis, adding a useful feature without requiring additional HTML markup.

Answer №2

I found myself in a situation where I couldn't use the code pointer-events:none because it was being used as a link. After reading a helpful response from user1271033, I experimented with different solutions. While some examples didn't quite do the trick for me, I discovered that inserting an empty div before the text within the truncated div solved my issue.

Here is an example of how I implemented this workaround:

<div style="text-overflow: ellipsis;white-space: nowrap; overflow: hidden;width:50px;">
    <div></div>
    Test test test
</div>

Answer №3

Have you considered trying out this ? It might be a good fit for your needs. Here are some examples:

<div class="name-holder">veryveryverylongname</div>
.name-holder {
    overflow: hidden;
    text-overflow: ellipsis;
    ...
    &:before {
        content: '';
        display: block;
    }

<div class="name-holder" data-name="veryveryverylongname"></div>
 .name-holder {
     overflow: hidden;
     text-overflow: ellipsis;
     ...
     &:before {
         content: attr(data-name);
     }

Answer №4

In order to remove the tooltip feature in Safari, you can use the pointer-events: none; property in your CSS. Keep in mind that this will disable all pointer events, including links.

Answer №5

Include some CSS in your code

 pointer-events: none;

You can even create a new CSS style and apply it wherever necessary.

Here is an example of how you can do it:

<div id="fix" title=""><a href="http://www.google.com"><span style="pointer-events:none;">Lorem ipsum dolor sit amet</span></a></div>

Take a look

https://jsfiddle.net/poojagayake/tx06vq09/1/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Strange outcomes observed with array created from HTML code

html : <input type="text" name="ps[part1['test']]" value="testing multiple array"> Current result : [ps] => Array ( [part1['test'] => testing multiple array ) Expecting result : [ps] => Array ( ...

What is the best way to implement a background image onto a card using state in React?

Currently, I have a React application with three cards on a single page. While I've successfully mapped the titles and text content to these cards, I'm struggling to figure out how to map background images to each card using the planet object. Ho ...

Facing issues connecting to my MongoDB database as I keep encountering the error message "Server Selection Timed Out After 3000ms" on MongoDB Compass

I am encountering an error on my terminal that says: { message: 'connect ECONNREFUSED 127.0.0.1:27017', name: 'MongooseServerSelectionError', reason: TopologyDescription { type: 'Single', setName: null, maxS ...

The Spring Boot and Angular Fusion Application

Currently, I am in the process of developing a Spring Boot Application with Angular as the frontend and Spring-Boot for the backend. My goal is to create a deployable war. After researching various resources online, my current understanding is that Spring ...

Guide to installing angular-ui-bootstrap through npm in angularjs application

My goal is to incorporate angular-ui-bootstrap into my project using the following steps: 1. npm install angular-ui-bootstrap 2. import uiBootstrap from 'angular-ui-bootstrap'; 3. angular.module('app', [      uiBootstrap    ]) I ...

utilizing ng-option to present choices in a dropdown menu

I have been implementing a scroll-down menu in my application using options. However, I now want to switch to using ng-option to populate the values from a JavaScript file. I also require assistance with writing AngularJS code for this task. Below is a s ...

What is the best way to name a force-directed Graph using d3?

I'm struggling to label the nodes in my force-directed graph created with d3.js. Despite trying various solutions from StackOverflow and online tutorials, I believe my issues stem from a lack of fundamental understanding of JavaScript. https://i.sstat ...

What are some creative ways to represent data using different numerical intervals?

Looking to develop a visualization of a .CSV file containing 1.2 million lines, showcasing addresses in the format: source , destination 12.251.512 , 12.623.743 51.734.312 , 23.233.991 6334.6231.123 , 42.532.54453 (utiliz ...

Exporting variables in node.js allows you to share data between different

Hi, I'm currently working with a file that looks like this: module.exports = { some variables that are being exported here, execute(message) { } } I want to export the message parameter to another file. I've attempted using var msg ...

Is there a way to determine the image type from a link like this?

I am wondering how to determine the image type from a link like the one below: For example, in HTML like this: <img src="https://www.gravatar.com/avatar/71b0d516013802a2d67aeb7c2e77ed32?s=48&amp;d=identicon&amp;r=PG&amp;f=1" alt="" width= ...

What is the best way to eliminate the occurrence of the word 'undefined' from the cycle output?

Can anyone assist with solving this issue? The webpage on JSFIDDLE displays 4 news containers, but an 'undefined' string appears before the first news container. I am looking to remove that 'undefined' string. Here is the HTML code: ...

Collaborative spreadsheet feature within a browser-based software platform

I am using an Angular-based SPA for my web application. My goal is to be able to open an Excel file within the application itself. Currently, I have a menu button or link that is linked to a specific path, for example //192.168.10.10/sharedExcels/myExcel. ...

Angular country selection dropdown featuring national flags

Can anyone help me find an Angular Bootstrap dropdown list of countries with flag icons and country codes? For example: United Kingdom - UK Please take a look at this reference image: https://i.sstatic.net/UEfvW.png I want the dropdown to resemble the o ...

Having trouble with innerHTML.value functionality?

Recently, I've been delving into creating a JavaScript program that fetches Wikipedia search results. Initially, everything seemed to be working fine as I was able to display the searched item using the alert() method. However, for some reason, it now ...

What methods can I use to evaluate the efficiency of my website?

Is there a way to assess and improve website performance in terms of load time, render time, and overall efficiency? I've heard of YSLOW for firebug, but am curious if there are any other tools or websites available for this purpose. ...

Tips for enforcing validation rules at the class level using Angular's version of jQuery Validate

After utilizing jQuery Validate's convenient addClassRules function to impose a rule on all elements of a specific class, rather than relying on the attributes of their name, I encountered a roadblock when trying to do the same with the Angular wrappe ...

Utilizing base classes in callbacks with ES6 in NodeJS

Consider this scenario where I have a class as shown below: class X extends Y { constructor() { super(); } method() { asyncMethod( function( err ) { super.method( err ); } ); } } The issue here is that super actually ...

Modifying the value of an item within a two-dimensional array

I've encountered a perplexing issue while working with a two-dimensional array named "grid" that holds objects known as "squares". In this scenario, each square simply keeps track of how many times it has been selected (clicked). After initializing t ...

What steps are involved in managing and retrieving data within session storage?

Here's an illustration of the data I receive after a successful ajax call response. The obj.DATA appears like this: { "A43D": { "FIRSTNAME": "Mike", "EMAIL": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b161 ...

applying various conditions to JavaScript arrays for filtering

After spending countless hours trying to solve my filtering issue, I'm still struggling. I'm in the middle of creating a react marketplace where users need to be able to apply multiple filters on one page. Here's an example of my product lis ...