Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS- how to prevent the original title info to be displayed

Tags:

html

css

I'm using the next simple html code -

<html lang="en">
  <head></head>
  <body>
    <a href="#" title="This is some information for our tooltip." class="tooltip">
     <span>CSS3 Tooltip</span>
    </a>
  </body>
</html>

And I've also added some css rules to make a nice tooltip when the mouse is hovering over the link

.tooltip {
    display: inline;
    position: relative;
}

.tooltip:hover:after{
    background: #333;
    background: rgba(0,0,0,.8);
    border-radius: 5px;
    bottom: 26px;
    color: #fff;
    content: attr(title);
    left: 20%;
    padding: 5px 15px;
    position: absolute;
    z-index: 98;
    width: 220px;
}

.tooltip:hover:before {
    border: solid;
    border-color: #333 transparent;
    border-width: 6px 6px 0 6px;
    bottom: 20px;
    content: "";
    left: 50%;
    position: absolute;
    z-index: 99;
}

The thing is that now I get the tooltip but also the original pop up of the title - enter image description here

Is there a way to make the white tooltip gone? and only by using a css rule?

Thanks for any kind of help

like image 935
PESfcs Avatar asked Nov 02 '25 03:11

PESfcs


1 Answers

Use data-* attribute instead.

.tooltip {
  display: inline;
  position: relative;
  top: 50px;
}
.tooltip:hover:after {
  background: #333;
  background: rgba(0, 0, 0, .8);
  border-radius: 5px;
  bottom: 26px;
  color: #fff;
  content: attr(data-title);
  left: 20%;
  padding: 5px 15px;
  position: absolute;
  z-index: 98;
  width: 220px;
}
.tooltip:hover:before {
  border: solid;
  border-color: #333 transparent;
  border-width: 6px 6px 0 6px;
  bottom: 20px;
  content: "";
  left: 50%;
  position: absolute;
  z-index: 99;
}
<a href="#" data-title="This is some information for our tooltip." class="tooltip"><span>CSS3 Tooltip</span></a>
like image 166
Weafs.py Avatar answered Nov 03 '25 18:11

Weafs.py



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!