Say Goodbye to Underlined Links: Learn How to Remove Them with these Easy CSS Code Examples

Table of content

  1. Introduction
  2. Why remove underlined links?
  3. CSS basics
  4. Example 1: Remove underlines from all links
  5. Example 2: Remove underlines from specific links
  6. Example 3: Remove underlines on hover
  7. Bonus tip: Change link colors
  8. Conclusion


If you're looking to improve the design of your website, one key aspect to consider is the appearance of hyperlinks. By default, most browsers will display these links using underlined text. While this can be functional, it may not always be the most aesthetically pleasing option. Fortunately, there is a simple solution: using Cascading Style Sheets (CSS), you can easily remove these underlines and customize the appearance of your links to better fit your website's design.

The process of removing underlines from links is quite simple, and can be accomplished with just a few lines of CSS code. By targeting the "a" (anchor) tag used to create hyperlinks, you can adjust its text-decoration property to remove the underline. From there, you can further customize the appearance of your links by modifying font sizes, colors, or other properties as desired.

Of course, there are additional considerations to keep in mind when using this technique, such as ensuring that your links remain easily identifiable for users. Nonetheless, learning how to remove underlines from links is a valuable skill for any web developer or designer. With the right CSS code and a little experimentation, you can take your website's design to the next level, creating a more polished and visually appealing user experience.

Removing the underlined links from a website may seem like a small change, but it can make a big difference in its aesthetic appeal. Underlined links have been a traditional design element on the web for many years, and some may find them distracting or outdated. With CSS code, web developers can easily remove the underlines from links and create a cleaner and more modern look for their websites.

In addition to aesthetics, removing underlined links can also make the links more distinguishable. By replacing the underline with a different styling option, such as bolding or changing the color, the links can stand out more and be easier to find for users. This is particularly important for websites with a lot of text, where links can easily get lost.

Another reason to remove underlined links is accessibility. Some users with visual impairments may have difficulty distinguishing between underlined text and regular text, and removing underlines can make the text easier for them to read. Additionally, some users with motor impairments may have difficulty clicking on underlined links with a mouse, making it more challenging to navigate the website. By removing the underlines from links, web developers can create a more inclusive and user-friendly website for all users.

CSS basics

CSS, or Cascading Style Sheets, is a coding language used to control the presentation of HTML markup on web pages. It allows developers to specify the layout, typography, and colors of a website, among other things. While there are many CSS properties and values to learn, there are a few basics that every programmer should understand.

CSS is written in separate files from your HTML code, usually with a .css extension. To link your CSS file to your HTML file, you need to include a link tag in the head section of your HTML document. Like this:

<!DOCTYPE html>
  <title>My Page</title>
  <link rel="stylesheet" type="text/css" href="style.css">

In this example, the link tag tells the browser to load the file style.css and apply its styles to the HTML document.

CSS uses selectors to target specific HTML elements and apply styles to them. A selector is a pattern of characters that matches one or more elements on a page. For example, the selector h1 would match all the h1 tags in the HTML document. Once you have selected an element, you can apply styles to it using CSS properties and values. For example, to set the font size of all the h1 tags to 24 pixels, you could use the following CSS code:

h1 {
  font-size: 24px;

CSS properties control the appearance of the elements they are applied to. For example, the font-size property sets the size of the font, while the color property sets the color of the text. CSS values specify how the properties should be applied. For example, 24px is a value for the font-size property, and red is a value for the color property.

Understanding these basics is essential for writing effective CSS code. Once you have mastered these concepts, you can start experimenting with more advanced CSS techniques to create beautiful and functional web pages.

To remove underlines from all links in your web page, use the CSS code text-decoration: none;. This will remove the underline from all links, regardless of their location or context.

To apply this code to all links on your page, add the following CSS rule to your style sheet:

a {
  text-decoration: none;

This code targets all links (a elements) and removes their text decoration, which includes underlines. You can add this code to your existing style sheet or create a new one.

Keep in mind that removing underlines from links can make it harder for users to distinguish between regular text and links. It's important to use other visual cues, such as color or hover effects, to indicate clickable links. Additionally, removing underlines from links may affect accessibility for users who rely on screen readers or have vision impairments. Consider using alternative methods, such as changing the color of links, instead of removing underlines entirely.

To remove underlines from specific links, we can use the :link and :visited selectors in CSS. This allows us to target only certain links on our website and apply different styles to them.

Here's an example of how to remove underlines from links with a specific class:, {
  text-decoration: none;

In this example, we are targeting links with the class "my-link-class" and applying the "text-decoration: none;" property to remove underlines.

We use both the :link and :visited selectors to ensure that the style is applied to both unvisited and visited links.

It's important to note that we need to include both selectors in the code for the style to work correctly. If we only used the :visited selector, for example, the style would only apply to visited links and not unvisited ones.

Overall, using CSS selectors like :link and :visited allows us to have more control over the styles applied to specific links on our website. By removing underlines from certain links, we can improve the overall aesthetic and usability of our website.

Example 3: Remove underlines on hover

To remove the underlines on hover, we will add a new rule that applies when the user hovers over a link. We will use the CSS pseudo-class :hover to target the link when the user hovers over it. Here's the code you can use:

a:hover {
  text-decoration: none;

This code targets all links (a elements) and removes the underline (text-decoration: none) when the user hovers over them (:hover). The result is a clean and polished look for your website or web application.

It's important to note that removing the underlines on hover can affect the user experience, as underlined links are a common indication of clickable elements on the web. You may want to consider using other visual cues or styling to make your links stand out and indicate their clickable nature. Also, keep in mind that removing underlines on hover may not be accessible to users who navigate the web using a keyboard, as they may not have the visual cue of a hover state.

Changing the colors of your links can help to make them stand out and draw more attention from your readers. To change the color of a link in CSS, you can use the color property, followed by the desired color value.

For example, if you want to change the color of all links on your website to red, you can add the following code to your CSS file:

a {
  color: red;

This will change the color of all links on your website to red. You can also target specific types of links by using more specific selectors.

For example, if you only want to change the color of links in your website's header, you can add the following code:

.header a {
  color: red;

This will only change the color of links that are inside the HTML element with the class header.

You can also use color names or hexadecimal color codes to specify the color you want. For example, to change the color of links to blue, you can use the following code:

a {
  color: blue;

Or, to use a specific shade of blue, you can use a hexadecimal color code:

a {
  color: #0077be;

Remember, when choosing colors for your links, it's important to make sure that they are still easy to read and don't blend in too much with the rest of your text. Play around with different colors until you find the one that works best for your website's design.


In , underlined links might be a familiar sight on your website or application, but with CSS code, you can easily remove them for a sleeker and more modern look. Whether you choose to remove all underlined links or only certain ones, the CSS code examples provided in this article offer a variety of methods to accomplish this task. Remember to always test your changes in different browsers to ensure they look and function as intended. By using CSS to remove underlined links, you can help your website or application stand out and provide a more polished user experience for your visitors.

Throughout my career, I have held positions ranging from Associate Software Engineer to Principal Engineer and have excelled in high-pressure environments. My passion and enthusiasm for my work drive me to get things done efficiently and effectively. I have a balanced mindset towards software development and testing, with a focus on design and underlying technologies. My experience in software development spans all aspects, including requirements gathering, design, coding, testing, and infrastructure. I specialize in developing distributed systems, web services, high-volume web applications, and ensuring scalability and availability using Amazon Web Services (EC2, ELBs, autoscaling, SimpleDB, SNS, SQS). Currently, I am focused on honing my skills in algorithms, data structures, and fast prototyping to develop and implement proof of concepts. Additionally, I possess good knowledge of analytics and have experience in implementing SiteCatalyst. As an open-source contributor, I am dedicated to contributing to the community and staying up-to-date with the latest technologies and industry trends.
Posts created 2989

Leave a Reply

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

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top