This is done using the CSS: hover attribute attached to the CSS rule of the parent node.
Consider the following HTML code:
<div class="parent"> <span class="label">Always on!</span> <span class="hiddenLabel">Show on Mouse</span> </div>
You get the effect you mentioned with the following css code:
.parent .hiddenLabel { visibility: hidden; } .parent:hover .hiddenLabel { visibility: visible; }
This basically tells the browser that when the “mouseover” event occurs on the “parent” node, nodes with the CSS class “hiddenLabel” will appear to the user and disappear when the mouse exits the node,
It is best practice to achieve this effect because of the loading and processing time required to run javascript on the page than loadable CSS.
Here is a great entry on pseudo selectors and what each of them does: http://css-tricks.com/pseudo-class-selectors/
source share