24

How would I make text appear under a link?

<div class="login">
    <a href="">Login
    <p>Access your profile here</p>
    </a>
</div> 

Where the login triggers the p to show?

Do I need to use the p or something else?

gsamaras
  • 71,951
  • 46
  • 188
  • 305
Xplo
  • 243
  • 1
  • 2
  • 6

5 Answers5

56

that's simple just add title attribute in tag

<a href="http://www.studyofcs.com" title="Tricks Site">Studyofcs</a>
Mohsin Shoukat
  • 1,190
  • 1
  • 13
  • 22
23

The following style makes the p visible on hover:

.login a p {display:none;}
.login a:hover p {display:block;}
<div class="login">
    <a href="">Login
        <p>Access your profile here</p>
    </a>
</div> 

Or if you want the whole link including p inside stay visible together on hover use the following:

.login a p {display:none;}
.login a:hover p {display:block;}
.login a:hover {display:block;}
<div class="login">
    <a href="">Login
        <p>Access your profile here</p>
    </a>
</div> 
Nima
  • 2,100
  • 2
  • 23
  • 32
  • 2
    nice one, I just combined this with a bootstrap label inside a span, this way every time you hover a label, a box will appear underneath it! Thx for this! – Alex Cio Feb 15 '17 at 15:35
8

Simple Html Tooltip

<a href="https://stackoverflow.com/" title="Where Developers Learn, Share, &amp; Build Careers">stackoverflow</a>

Tooltip Using Bootstrap :

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h3>Tooltip Example</h3>
  <p>The data-placement attribute specifies the tooltip position.</p>
  <ul class="list-inline">
    <li><a href="#" data-toggle="tooltip" data-placement="top" title="Hooray!">Top</a></li>
    <li><a href="#" data-toggle="tooltip" data-placement="bottom" title="Hooray!">Bottom</a></li>
    <li><a href="#" data-toggle="tooltip" data-placement="left" title="Hooray!">Left</a></li>
    <li><a href="#" data-toggle="tooltip" data-placement="right" title="Hooray!">Right</a></li>
  </ul>
</div>

<script>
$(document).ready(function(){
  $('[data-toggle="tooltip"]').tooltip();   
});
</script>

</body>
</html>

You can achieve hover tooltip By Bootstrap+JQuery also :

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h3>Tooltip Example</h3>
  <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
</div>

<script>
$(document).ready(function(){
  $('[data-toggle="tooltip"]').tooltip();   
});
</script>

</body>
</html>
Mujahid Khan
  • 1,712
  • 1
  • 18
  • 24
6

In case you are using bootstrap you can use the following:

<a class="login" href="" data-toogle="tooltip" title="Access your profile here">Login</a>

0

You just can use old title argument, works well, the shortest solution

Google

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 15 '22 at 06:01