Table Fade Effect

Focus on the data that matters. This effect dims the opacity of the entire table when hovered, but keeps the specific row under the mouse fully visible and highlighted.

#ProductPriceStock
1Laptop Pro$1200In Stock
2Smartphone X$800Low Stock
3Tablet Mini$400Out of Stock
4Wireless Buds$150In Stock
5Smart Watch$250In Stock

Hover over the rows above.

Copy the Script

<style>
/* Dim all rows when table body is hovered */
.hover-table tbody:hover tr {
    opacity: 0.4;
}

/* Restore opacity for the specific row being hovered */
.hover-table tbody tr:hover {
    opacity: 1;
    background-color: #f8f9fa;
    font-weight: bold;
}

/* Smooth transition */
.hover-table tbody tr {
    transition: opacity 0.3s;
}
</style>

<table class="hover-table">
  ...
</table>

Frequently Asked Questions

It can be, but the most efficient way is using CSS `:hover` selectors. This creates a smoother 60fps animation without using JavaScript resources.

Highlighting columns on hover is complex in CSS alone. You usually need JavaScript to find the index of the cell and apply a class to all cells with that index.

Yes. You just need to adjust the opacity levels. Instead of fading to `0.5`, you might change the background color brightness.