Add hover text without JavaScript like we hover on a user’s profile using HTML and CSS.
To display hover text (often called a tooltip) without JavaScript, you can use the title attribute in HTML or the :hover pseudo-class in CSS. Here’s how:
Using the title attribute:
When you hover over the link, the browser will display the tooltip with the text “Click here to view the profile.”
Using CSS :hover for custom styling:
User Profile
Click here to view the profile
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: white;
text-align: center;
border-radius: 5px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 100%;
left: 50%;
margin-left: -60px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
This example shows a custom tooltip when you hover over the “User Profile” link, all without JavaScript.