4 Ways to Animate the Color of a Text Link on Hover

Good writeup by Katherine Kato of several techniques on how to change the color of a link on hover, animated

Let’s create a pure CSS effect that changes the color of a text link on hover… but slide that new color in instead of simply swapping colors.

There are four different techniques we can use to do this. Let’s look at those while being mindful of important things, like accessibility, performance, and browser support in mind.

When looking only at the code, I’m more a fan of the background-clip: text technique as it does not require you to duplicate the text into a data-* attribute. It does however has some nasty side-effects such as no longer displaying text-decorations and shadows.

If we only had something like content: text-content; in CSS, then we could remove the data-* content duplication requirement.

4 Ways to Animate the Color of a Text Link on Hover →

💄 Apart from animating only color, I also like animating the separate text-decoration-* properties or background-size on hover.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.