Believemy logo purple

Create a very modern hover on a link

Here's an easy way to create a very modern hover on a link! There are lots of possible effects for buttons and links: the better they look, the more likely your users will be to click on them.
Updated on December 9, 2024
Believemy logo

Here's how to easily create a very modern hover effect on a link! There are many possible effects on buttons and links: the more successful they are, the more your users will want to click on them.

You can find the entire tutorial on our Instagram account.

 

Step 1

Let's start with the HTML code.

HTML
<a href="#">Read the Article</a>

So simple that we can skip the explanations. You can also use a class instead of directly selecting the a tag.

 

Step 2

Now we need to style our link to start giving it some style.

CSS
a {
  text-decoration: none;
  color: black;
  font-size: 1.4em;
  position: relative;
  padding: 0 15px;
  transition: .2s all;
  font-weight: 300;
}

 

Step 3

Let's add a small border before the text, using the ::before selector, which allows us to apply various properties to a space that is located before the element.

CSS
a::before {
  content: '';
  position: absolute;
  background: #4cd3c2;
  width: 2px;
  height: 100%;
  left: 0;
  transition: .2s all;
  z-index: -1;
}

By using the content property, we enable the display of the border, because otherwise the browser will display nothing, as the element is empty.

We then define the border with position absolute. Thanks to the position relative set on the link (a), the border will adapt to the link and not to the page.

Finally, we give it a z-index of -1 so that the border is hidden beneath the text in the next step.

 

Step 4

Let's make it dynamic!

CSS
a:hover::before {
  width: 100%;
}
a:hover {
  color: #ffffff;
  font-size: 1.6em;
}
Category: Development
Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Try for Free

Whether you're scaling your startup, building your first website, or transitioning to a developer role, Believemy is your new home. Join us, grow, and let’s build your project together.

Believemy is with anyone