Make hyperlink underline appear on mouseover (currently the opposite)

Make hyperlink underline appear on mouseover (currently the opposite)

August 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Make hyperlink underline appear on mouseover (currently the opposite)

In this article, we’ll help you reverse the default hyperlink underline behavior in your Magento store. By default, links are underlined before mouseover and lose their underline when hovered. We’ll show you how to achieve the opposite effect - a link that is not underlined until it’s hovered over.

Understanding the Current Behavior

Let’s first understand what’s happening currently in your Modern theme f001.

By default, Magento applies CSS styles to links (.magneto-a) that include text-decoration: underline;. This causes all links to be underlined by default. When a user hovers over a link, this style is removed with .magneto-a:hover { text-decoration: none; }.

This is why your links are already underlined and lose their underline when hovered.

To achieve the desired effect, we need to flip these styles:

  1. Remove the default underline: We’ll remove the text-decoration: underline; style applied to all links.
  2. Apply an underline on hover: We’ll add a new style that applies text-decoration: underline; when a link is hovered.

Let’s dive into the code changes required for this.

Step-by-Step Guide

  1. Remove the Default Underline

Open your theme’s CSS file (usually located in pub/static/frontend/Your_Theme/theme/css/source/_extend.less or similar) and look for the .magneto-a selector:

.magneto-a {
    text-decoration: underline;
}

Comment out this line by adding a forward slash (//) at the beginning, like so:

// .magneto-a {
//     text-decoration: underline;
// }

This will remove the default underline.

  1. Apply Underline on Hover

Next, add a new style that applies an underline when a link is hovered:

Add this code below the .magneto-a selector:

.magneto-a:hover {
    text-decoration: underline;
}
  1. Save and Deploy

After making these changes, save your CSS file.

To deploy the changes to your live store:

  • If you’re using a local development environment, run bin/magento setup:static-content:deploy in the terminal.
  • If your site is hosted on an external server, ask your hosting provider about their deployment process.

Conclusion

Congratulations! You’ve now successfully reversed the hyperlink underline behavior in your Magento store. Your links will no longer be underlined by default and will only become underlined when hovered over.

Remember, it’s crucial to always backup your files before making extensive changes like this. Test thoroughly on a staging environment first if possible.

If you need further help with customizing your Magento theme or have other development questions, feel free to check out Laravel Company for professional e-commerce solutions and technical expertise.

Themes SEO

Our network