Remove the underline from a Link in React

Guide: Remove the underline from a Link in React

Glasshost
2 min readMay 1, 2023

When working with React, you may have noticed that links are underlined by default. This can be problematic if you want to customize the appearance of your links. In this guide, we will show you how to remove the underline from a link in React.

Using CSS

The easiest way to remove the underline from a link in React is to use CSS. You can use the `text-decoration` property to remove the underline from your link. Here’s an example:

a {
text-decoration: none;
}

This will remove the underline from all links on your page. If you only want to remove the underline from a specific link, you can use a class or ID selector to target that link.

a.custom-link {
text-decoration: none;
}

In this example, we are using the class selector `.custom-link` to target a specific link.

Using styled-components

If you’re using styled-components in your React project, you can also remove the underline from a link using the `text-decoration` property. Here’s an example:

import styled from 'styled-components';

const Link = styled.a`
text-decoration: none;
`;

In this example, we are creating a styled component called `Link` that removes the underline from the link using the `text-decoration` property.

Conclusion

Removing the underline from a link in React is a simple task that can be accomplished with CSS or styled-components. By using one of these methods, you can easily customize the appearance of your links to match your design.

--

--

Glasshost

Hey, I am Shivam Kumar, Founder of GlassHost.tech. We offer some very competitive hosting solutions and solve coding issues/problems. Visit Glasshost.tech now.