Posted on Feb. 5, 2021, 8 p.m. by Bishal ( 2961)
<div></div>
tag defines a division in a HTML file. The <div></div>
tag can be used with class=""
and id=""
attribute to style (using CSS or JavaScript) and add functionalities (using JavaScript). Usually, it is used as a container in a HTML document. Any HTML elements can be wrapped inside a <div></div>
. The HTML <div></div>
is also used to make a webpage responsive by wrapping an element. In this blog I am going to create a simple CSS text visible on Hover effect using HTML and CSS.
<div></div>
is a block-level element. That is, it always starts on a new line. For example, :
div{
display: block;
}
Hover over me
Here is the text that is only visible on hover
index.html
index.html
<!DOCTYPE html>
<html>
<head>
<title>Text visible on hover - Code With Bishal</title>
</head>
<!-- created by Code With Bishal - www.codewithbishal.com
-->
<body>
</body>
</html>
style.css
<head> </head>
of your HTML document:
<link rel="stylesheet" href="style.css">
style.css
file
.visible{
font-size: 30px;
background: transparent;
text-align: center;
color: red;
}
.hidden{
border: 1px solid #ccc;
display: none;
font-size: 25px;
margin-top: 20px;
padding: 5px;
text-transform: uppercase;
}
.visible:hover .hidden{
display: block;
}
<!DOCTYPE html>
<html>
<head>
<title>Text visible on hover by Code With Bishal</title>
</head>
<body>
<!-- by Code With Bishal - www.codewithbishal.com -->
<div class="visible">
<p> Hover over me </p>
<span class="hidden">
Here is the text that is only visible on hover
</span>
</div>
</body>
</html>
.visible{
font-size: 30px;
background: transparent;
text-align: center;
color: red;
}
.hidden{
border: 1px solid #ccc;
display: none;
font-size: 25px;
margin-top: 20px;
padding: 5px;
text-transform: uppercase;
}
.visible:hover .hidden{
display: block;
}