How to Display Element on Hover using CSS ? Last Updated : 22 Mar, 2024 Comments Improve Suggest changes Like Article Like Report In web development, displaying an element on hover is a common interaction pattern used to reveal additional content or actions. Below are the various CSS approaches to achieve this effect: Table of Content Using the display propertyUsing the visibility propertyUsing the display propertyThis approach makes a hidden element appear when we hover over another element. It works by changing the display property of the hidden element from none to block when we hover over the element that contains it. Example: The below code will explain the use of the display property to display elements on hover in CSS. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title> Display Element on Hover </title> <style> h3, .parent-element { text-align: center; } .hidden-element { display: none; } .parent-element:hover .hidden-element { color: blue; display: block; margin: auto; height: 50px; width: 200px; border: 1px solid green; border-radius: 5px; } </style> </head> <body style="text-align: center;"> <h2> Using CSS display property </h2> <h3> Hover the below text to see <br/>hidden content </h3> <div class="parent-element"> Hover over me <br/> <div class="hidden-element"> I'm visible now! </div> </div> </body> </html> Output: Using the visibility propertyThis approach involves toggling the visibility property of an element between hidden and visible to show or hide it on hover. Using visibility allows the element to remain in the layout, affecting the positioning of other elements around it. Example: The below code uses the visibility property to display elements on hover using CSS. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title> Display Element on Hover </title> <style> h3, .parent-element { text-align: center; } .hidden-element { visibility: hidden; opacity: 0; transition: visibility 0s, opacity 0.5s ease; } .parent-element:hover .hidden-element { color: green; visibility: visible; opacity: 1; } </style> </head> <body style="text-align: center;"> <h2> Using CSS visibility property </h2> <h3> Hover the below text to see the <br/> hidden content. </h3> <div class="parent-element"> Welcome to GFG! <div class="hidden-element"> GeeksforGeeks is a olnline learning platform </div> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Display Element on Hover using CSS ? Y yuvrajghule281 Follow Improve Article Tags : Web Technologies CSS CSS-Questions Similar Reads Display div element on hovering over <a> tag using CSS We will render the div element by hovering over the <a> tag using CSS. We can apply an adjacent sibling CSS selector property to the <a> tag that will display the hidden div element's content while hovering over it. The Adjacent sibling selector is a CSS Combinators, used to select the e 2 min read How to create icon hover effect using CSS ? To style an icon's color, size, and shadow using CSS, use the color property to set the icon's color, font size to adjust its size, and text-shadow or box-shadow for adding shadow effects, creating a visually appealing and dynamic look.Using: hover Pseudo-ClassUsing the: hover pseudo-class, you can 2 min read How to Modify Hover Effect using Tailwind CSS ? In Tailwind CSS, the term "modify hover" refers to changing the styles that are applied to an element when it is hovered over. With Tailwind CSS "hover" variation, you can quickly apply particular utility classes and custom classes to control how components appear when you hover over them, giving yo 3 min read How to make Profile Card Hover Effect using CSS ? Almost all of us must have heard that 'the first impression is the last impression'. The profile card carries the most important details we should know about a person at the very first instant. A better impression attracts more traffic. So to engage more audience in a website it is very important to 3 min read Display Content on hovering Card using CSS In this article, we will see how we can create a card that displays content on hovering using the hover property using HTML and CSS.HTML Code: In this section, we will create the structure of our HTML card. Create a "div" with class name "card".Create another "div" inside the main "div" with class n 3 min read Like