Unlimited Wordpress themes, plugins, graphics & courses! Unlimited asset downloads! From $16.50/m
  1. Web Design
  2. CSS

Exploring Creative CSS Hover Effects for Inline Links

Read Time:6 minsLanguages:

In this tutorial we’re talking about CSS hover effects. And not just any hover effects either! We’re going to create some much more interesting alternatives to the standard inline link effects we’ve all been using for years.

Creative Link Hover Demos

I’ve created a quick demo to show all these link effects; a series of list items arranged with CSS Grid, and in each one I’ll place an inline link which can be styled. Take a look at each one, feel free to fork the demo, and see what you can do with them!

CSS Inline Link Hover Effects

Check out the video, or read on for more explanations!

Global Styles

For all these demos I first set some global styles and variables for the a elements:

I’ve added an id to each link so I can target them all easily.

Hover Effect 1: Background Box Shadow

This effect will swipe a background box shadow across the inline link, changing the color of the link text as it does so.

hover effect 1hover effect 1hover effect 1
  • We begin by adding some padding all around the link, then to prevent that padding upsetting the flow of the text we add a negative margin of the same value.
  • Instead of using the background property we use box-shadow because we can transition it.

Hover Effect 2: Animated Underline

Our second effect adds an underline, but animates it from the middle of the text outwards for some extra dynamism.

hover effect 2hover effect 2hover effect 2
  • The first thing to do is give the anchor a position: relative; because we’ll be using pseudo elements which we want to position on it.
  • We use the ::before pseudo element which we position top: 100%; to make it sit along the bottom of the link.
  • We use transform: scaleX(); and transition to animate the pseudo element.
  • We transition the color of the link too, to match the underline animation.

Hover Effect 3: Passing Underline

When you hover over this link you’ll see the underline animate in from the left, then disappear to the right.

hover effect 3hover effect 3hover effect 3
  • We start again with position: relative; on the parent element because we’ll be working with a pseudo element.
  • We style the ::before with some basic rules, including a border-radius: 4px; just to give it a slightly softer look.
  • We’ll use the same transition transform idea as the previous demo (transform: scaleX(0);) but we’ll change the transform origins.
  • So we begin by setting transform-origin: right; on the ::before element.
  • Then on the :hover we use transform-origin: left;.

Hover Effect 4: Text Replace

This hover effect is the most complex and the first one we’ll change the markup for. We’ll be replacing the link text with whatever we store in a data-attribute on the link.

hover effect 4hover effect 4hover effect 4
  • Start with the usual position: relative; style on the parent.
  • Define basic styles for the ::before and ::after pseudo elements.
  • Our ::before element will be the underline.
  • The ::after element will hold the text we set in the data-replace="" attribute (which will match the link text). We set this with content: attr(data-replace);.
  • We push the ::after element to the right by using transform: translate3d(); (to take advantage of hardware acceleration).
  • We also need to make it invisible which we do with an overflow: hidden; in combination with display: inline-block; on the parent.
  • On :hover we move the ::after element back into position.
  • We wrap the text link in a <span> element, which we then transition out of the link as the ::after element transitions in, and vice versa.

Hover Effect 5: Multiple Properties

Let’s make things a little simpler again. This example uses a handful of different properties to give a growing offset background effect.

hover effect 5hover effect 5hover effect 5
  • Begin with the usual setup styles which we need to manipulate pseudo elements.
  • Set a z-index: -1; to send the block behind the link text.
  • Offset the ::before element on hover by using a negative margin, and expressing the width as calc(100% + 10px);

Hover Effect 6: Multi-Line Gradient

The effects so far work well when the inline links sit on one line, but what if the link spreads across multiple lines? Let’s have a play with an effect which works in that scenario.

hover effect 6hover effect 6hover effect 6
  • Use a long link to best see the effect for this one.
  • We apply a background gradient for the bottom border.
  • It looks like this: background-image: linear-gradient(white 50%, var(--link-2) 50%); and gives us a background which is half white, half blue to start with.
  • We then use a background-size: auto 175%; to scale the background gradient 175% vertically. This effectively enlarges the whole background, which is aligned to the top edge, cropping much of the blue in the process. In this way we create our underline.
  • On hover, we position the background so that it aligns with the bottom of the link instead.


Nothing beats a good practical tutorial eh? I hope you enjoyed creating these link effects and developing your skills as you progressed through them. Don’t forget you can watch the video at the top of the page for a more visual explanation of these hover effects. Thanks for watching/reading!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.