Remove underline and link from tooltip












0















I try to implement a tooltip with picture. That works. But I have 2 problems:




  1. If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).

  2. I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.


HTML:



<div class="col-lg-4">
<a href="#">
<div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
</a>
</div>


CSS:



a .hover-img {
position:relative;
}
a .hover-img span {
position:absolute; left:-9999px; top:-9999px; z-index:9999;
border: 2px solid #000;

}
a:hover .hover-img span {
top: 40px;
left: 0;
}
.dotted {
color: #4e555b;
border-bottom: 2px dashed #4e555b;
text-decoration: none!important;
}
.dotted:hover {
text-decoration: none!important;
}


JSFiddle:



https://jsfiddle.net/kdzb108h/










share|improve this question



























    0















    I try to implement a tooltip with picture. That works. But I have 2 problems:




    1. If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).

    2. I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.


    HTML:



    <div class="col-lg-4">
    <a href="#">
    <div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
    </a>
    </div>


    CSS:



    a .hover-img {
    position:relative;
    }
    a .hover-img span {
    position:absolute; left:-9999px; top:-9999px; z-index:9999;
    border: 2px solid #000;

    }
    a:hover .hover-img span {
    top: 40px;
    left: 0;
    }
    .dotted {
    color: #4e555b;
    border-bottom: 2px dashed #4e555b;
    text-decoration: none!important;
    }
    .dotted:hover {
    text-decoration: none!important;
    }


    JSFiddle:



    https://jsfiddle.net/kdzb108h/










    share|improve this question

























      0












      0








      0








      I try to implement a tooltip with picture. That works. But I have 2 problems:




      1. If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).

      2. I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.


      HTML:



      <div class="col-lg-4">
      <a href="#">
      <div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
      </a>
      </div>


      CSS:



      a .hover-img {
      position:relative;
      }
      a .hover-img span {
      position:absolute; left:-9999px; top:-9999px; z-index:9999;
      border: 2px solid #000;

      }
      a:hover .hover-img span {
      top: 40px;
      left: 0;
      }
      .dotted {
      color: #4e555b;
      border-bottom: 2px dashed #4e555b;
      text-decoration: none!important;
      }
      .dotted:hover {
      text-decoration: none!important;
      }


      JSFiddle:



      https://jsfiddle.net/kdzb108h/










      share|improve this question














      I try to implement a tooltip with picture. That works. But I have 2 problems:




      1. If I move mouse over word TooltipText only a dashed line should be displayed. But the word is also underlined (because Link).

      2. I would like to disable the link, since it is a tooltip. The CSS attribute 'pointer-events: none;' disables the link, but then the tooltip is not working.


      HTML:



      <div class="col-lg-4">
      <a href="#">
      <div class="hover-img"><strong class="dotted">TooltipText</strong><span><img src="https://via.placeholder.com/350x150"/></span></div>
      </a>
      </div>


      CSS:



      a .hover-img {
      position:relative;
      }
      a .hover-img span {
      position:absolute; left:-9999px; top:-9999px; z-index:9999;
      border: 2px solid #000;

      }
      a:hover .hover-img span {
      top: 40px;
      left: 0;
      }
      .dotted {
      color: #4e555b;
      border-bottom: 2px dashed #4e555b;
      text-decoration: none!important;
      }
      .dotted:hover {
      text-decoration: none!important;
      }


      JSFiddle:



      https://jsfiddle.net/kdzb108h/







      html css






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 19 at 20:31









      StampyStampy

      165318




      165318
























          4 Answers
          4






          active

          oldest

          votes


















          1














          Add this:



           a  {
          text-decoration: none;
          }


          text-decoration should be applied directly to <a>, not to its child tags.



          Refer to: https://jsfiddle.net/ewtysb4c/






          share|improve this answer































            1














            The word is underlined because the <a> tag has a href attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.



            However, the cursor will also not behave like a link. You could enforce the text-decoration: none in the <a> tag and add a cursor: pointer to the the a:hover rules. I'd suggest you create an a.tooltip-link class and add these styles to it so they won't be applied to all <a> tags in your page.






            share|improve this answer































              0















              1. The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.






              share|improve this answer































                0














                So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
                Second thing. I'd rather make the structure next way:



                <div class="wrapper objects">
                <div class="object">
                <p class="tooltip-provoke">Tooltip Text</p>
                <div class="tooltip-text">
                <img src="https://via.placeholder.com/350x150"/>
                </div>
                </div>
                </div>


                Than set div.tooltip-text display:block, and change it by hovering p.tooltip-provoke. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
                You can see example here: https://jsfiddle.net/0pmknx4g/9/






                share|improve this answer























                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54271125%2fremove-underline-and-link-from-tooltip%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  1














                  Add this:



                   a  {
                  text-decoration: none;
                  }


                  text-decoration should be applied directly to <a>, not to its child tags.



                  Refer to: https://jsfiddle.net/ewtysb4c/






                  share|improve this answer




























                    1














                    Add this:



                     a  {
                    text-decoration: none;
                    }


                    text-decoration should be applied directly to <a>, not to its child tags.



                    Refer to: https://jsfiddle.net/ewtysb4c/






                    share|improve this answer


























                      1












                      1








                      1







                      Add this:



                       a  {
                      text-decoration: none;
                      }


                      text-decoration should be applied directly to <a>, not to its child tags.



                      Refer to: https://jsfiddle.net/ewtysb4c/






                      share|improve this answer













                      Add this:



                       a  {
                      text-decoration: none;
                      }


                      text-decoration should be applied directly to <a>, not to its child tags.



                      Refer to: https://jsfiddle.net/ewtysb4c/







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 19 at 20:42









                      AjitZeroAjitZero

                      119212




                      119212

























                          1














                          The word is underlined because the <a> tag has a href attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.



                          However, the cursor will also not behave like a link. You could enforce the text-decoration: none in the <a> tag and add a cursor: pointer to the the a:hover rules. I'd suggest you create an a.tooltip-link class and add these styles to it so they won't be applied to all <a> tags in your page.






                          share|improve this answer




























                            1














                            The word is underlined because the <a> tag has a href attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.



                            However, the cursor will also not behave like a link. You could enforce the text-decoration: none in the <a> tag and add a cursor: pointer to the the a:hover rules. I'd suggest you create an a.tooltip-link class and add these styles to it so they won't be applied to all <a> tags in your page.






                            share|improve this answer


























                              1












                              1








                              1







                              The word is underlined because the <a> tag has a href attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.



                              However, the cursor will also not behave like a link. You could enforce the text-decoration: none in the <a> tag and add a cursor: pointer to the the a:hover rules. I'd suggest you create an a.tooltip-link class and add these styles to it so they won't be applied to all <a> tags in your page.






                              share|improve this answer













                              The word is underlined because the <a> tag has a href attribute. If you remove the attribute, both the underline will disappear and the link will be disabled.



                              However, the cursor will also not behave like a link. You could enforce the text-decoration: none in the <a> tag and add a cursor: pointer to the the a:hover rules. I'd suggest you create an a.tooltip-link class and add these styles to it so they won't be applied to all <a> tags in your page.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jan 19 at 20:45









                              Guilherme VieiraGuilherme Vieira

                              596




                              596























                                  0















                                  1. The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.






                                  share|improve this answer




























                                    0















                                    1. The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.






                                    share|improve this answer


























                                      0












                                      0








                                      0








                                      1. The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.






                                      share|improve this answer














                                      1. The .dotted class is being applied to the 'strong' element, this does not have a text-decoration property. You need to apply a class to the 'a href="#"' tag and set the text-decoration: none; on that element.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jan 19 at 20:39









                                      Matthew PageMatthew Page

                                      592112




                                      592112























                                          0














                                          So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
                                          Second thing. I'd rather make the structure next way:



                                          <div class="wrapper objects">
                                          <div class="object">
                                          <p class="tooltip-provoke">Tooltip Text</p>
                                          <div class="tooltip-text">
                                          <img src="https://via.placeholder.com/350x150"/>
                                          </div>
                                          </div>
                                          </div>


                                          Than set div.tooltip-text display:block, and change it by hovering p.tooltip-provoke. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
                                          You can see example here: https://jsfiddle.net/0pmknx4g/9/






                                          share|improve this answer




























                                            0














                                            So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
                                            Second thing. I'd rather make the structure next way:



                                            <div class="wrapper objects">
                                            <div class="object">
                                            <p class="tooltip-provoke">Tooltip Text</p>
                                            <div class="tooltip-text">
                                            <img src="https://via.placeholder.com/350x150"/>
                                            </div>
                                            </div>
                                            </div>


                                            Than set div.tooltip-text display:block, and change it by hovering p.tooltip-provoke. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
                                            You can see example here: https://jsfiddle.net/0pmknx4g/9/






                                            share|improve this answer


























                                              0












                                              0








                                              0







                                              So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
                                              Second thing. I'd rather make the structure next way:



                                              <div class="wrapper objects">
                                              <div class="object">
                                              <p class="tooltip-provoke">Tooltip Text</p>
                                              <div class="tooltip-text">
                                              <img src="https://via.placeholder.com/350x150"/>
                                              </div>
                                              </div>
                                              </div>


                                              Than set div.tooltip-text display:block, and change it by hovering p.tooltip-provoke. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
                                              You can see example here: https://jsfiddle.net/0pmknx4g/9/






                                              share|improve this answer













                                              So, first of all want to explaint few things. You used as container, what's wrong. If you see any year w3.org documentation, you'll see that link is inline document. This link here: https://www.w3.org/TR/html401/struct/global.html#h-7.5.3 says, that inline elements can contain only other inline elements or text.
                                              Second thing. I'd rather make the structure next way:



                                              <div class="wrapper objects">
                                              <div class="object">
                                              <p class="tooltip-provoke">Tooltip Text</p>
                                              <div class="tooltip-text">
                                              <img src="https://via.placeholder.com/350x150"/>
                                              </div>
                                              </div>
                                              </div>


                                              Than set div.tooltip-text display:block, and change it by hovering p.tooltip-provoke. By using + in css ('.a + .b') you say to apply styles to first element after element with class="a" and only if it's class="b".
                                              You can see example here: https://jsfiddle.net/0pmknx4g/9/







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Jan 19 at 21:16









                                              NikitaNikita

                                              614




                                              614






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54271125%2fremove-underline-and-link-from-tooltip%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Homophylophilia

                                                  Updating UILabel text programmatically using a function

                                                  Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage