×

How to create a link with no underline in HTML

In HTML, an anchor tag (<a>) is a Styled Container tag, which means when a hyperlink is created using this, browsers, by default, display the link by applying some styles to it. These styles can include text color, text decoration, font size, etc. Therefore, these styles, which are mentioned in the user agent stylesheet of the browser, add an underline to the hyperlink and then display it on the webpage. But if the developer does not want an underline to the hyperlinks, these can be easily done.

Let us understand how to do it.

First of all, we need to know that hyperlinks have four different states when they appear on the browser, and according to these states, the default styles on it vary.

  1. a:link – This is a normal link, and it specifies that the link is not yet visited. In most browsers, these links are blue in color with an underline.
  2. a:visited – This specifies that the link has been visited, and most browsers display these in purple color with an underline.
  3. a:hover – This specifies a state when a user hovers its mouse on the link. Developers can add their desired styles to display during this state.
  4. a:active – This specifies that the link is currently active, and most browsers tend to display it in red color with an underline.

Example

<!DOCTYPE html>
<html>
<head>
<title>Hyperlinks</title>
</head>
<style>
a:link
{
color: blue;
}
a:visited
{
color: purple;
}
a:hover 
{
color: brown;
}
a:hover
{
color: red;
}
</style>
<body>
<h1><a href="https://xyz.com/">Click Here</a></h1>
</body>
</html>

Output

An unvisited link looks as:

How to create a link with no underline in HTML?

A visited link looks as:

How to create a link with no underline in HTML?

A Link when its hovered is shown as below:

How to create a link with no underline in HTML?

An active link is shown like below

How to create a link with no underline in HTML?

As you are seeing these links have underline, let’s see how to remove an underline from the link.

A hyperlink can be created without an underline just by targeting that particular anchor tag with the help of using selectors and setting a style named ‘text-decoration’ to none.

This can be done by specifying inline styles or mentioning internal style, or using an external CSS stylesheet and linking it to the HTML document.

Let's see all the ways mentioned above one by one.

1) Using inline style

A style named text-decoration is set to underline by the browser, which underlines the hyperlink. So, by using inline styles and specifying the 'text-decoration' from 'underline' to 'none' we will be able to achieve our target.

Example

Before specifying text-decoration to none.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using inline styles</title>
</head>
<body>
<h1><a href="https://www.google.com/">Click here to go to Google!</a></h1>
</body>
</html>

Output

How to create a link with no underline in HTML?

Example

After specifying text-decoration to none.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using inline styles</title>
</head>
<body>
<h1><a href="https://www.google.com/" style="text-decoration:none;">Click here to go to Google!</a></h1>
</body>
</html>

Output

How to create a link with no underline in HTML?

2) Using internal style

Besides using an inline style, we can also do the same with the help of internal styles. An internal style is specified inside the ‘<head>’ tag under the ‘<style>’ tag in the same way by targeting that particular link and setting its text-decoration to none, an underline can be removed.

Example

Before specifying text-decoration to none.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using internal styles</title>
</head>
<body>
<h1><a href="https://www.google.com/">Click here to go to Google!</a></h1>
</body>
</html>

Output

How to create a link with no underline in HTML?

Example

After specifying text-decoration to none.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using internal styles</title>
<style>
a
{
text-decoration: none;
}
</style>
</head>
<body>
  <h1><a href="https://www.google.com/" style="text-decoration:none;">Click here to go to Google!</a></h1>
</body>
</html>

Output

How to create a link with no underline in HTML?

3) Using an external stylesheet

Linking an external stylesheet and defining that particular hyperlink’s text-decoration to none is another way to do the same. An external stylesheet is linked to the HTML document using the '<link>' tag and mentioning the address of that linked document.

Example

Before specifying text-decoration to none.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using external stylesheet</title>
</head>
<body>
<h1><a href="https://www.google.com/">Click here to go to Google!</a></h1>
</body>
</html>

Output

How to create a link with no underline in HTML?

Example

After specifying text-decoration to none.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using external stylesheet</title>
<link rel="stylesheet" href="/pstyles/index.css">
</head>
<body>
<h1><a href="https://www.google.com/">Click here to go to Google!</a></h1>
</body>
</html>

External Stylesheet Code

a
{
    text-decoration: none;
}

Output

How to create a link with no underline in HTML?

Related Topics

How to change text color in HTML

Changing the text colour of a web page is essential because it enhances readability. There are several ways to change the colour of the text in HTML, which are as follows: Text...

7 minutes read.

HTML Code Tag

The code tag in HTML is a phrase tag used to insert a piece of computer programming code. In HTML there is a separate tag named as <code> tag. Sometimes,...

3 minutes read.

Most Commonly used Tags in HTML

In this tutorial, we'll look at the most popular HTML tags. We know HTML is a fundamental requirement for creating a website. As a result, it is essential to remember...

9 minutes read.

HTML Attributes

HTML Attributes provide the additional information about HTML elements. Attributes are always specified in the start tag. Attributes usually comes in pairs. lang Attribute This attribute helps in declaring the language...

2 minutes read.

How to append HTML code to a div using JavaScript?

In HTML, we have a div tag which is used to create a box where we can put a lot of other tags. So it works like a container. So,...

4 minutes read.

Html &lt;Col> Tag

You can write the col tag inside the table tag after the thead, tbody, foot, and tr tags. You can also apply it after the caption tag (in which the...

4 minutes read.

Font tag in HTML

HTML stands for Hypertext Mark-up Language and is used to create web pages and other information that can be later displayed in a web browser. It also consists of a...

4 minutes read.

HTML <address> Tag

Hyper Text Markup Language, HTML is the best markup language for creating Web pages. HTML consists of a wide variety of elements. In all of these elements, one element is...

4 minutes read.

HTML Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.

HTML <svg> tag

SVG is used to determine the vector-based graphics in XML format. What is SVG? We utilize SVG tag to specify visuals for the website. The attribute of SVG in a HTML document...

2 minutes read.

How to create a link with no underline in HTML

In HTML, an anchor tag (<a>) is a Styled Container tag, which means when a hyperlink is created using this, browsers, by default, display the link by applying some styles...

5 minutes read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user. You can use the id attribute...

3 minutes read.

HTML Forms

Forms are required when we want to collect data from the user. Html forms consists of different fields to take user inputs such as: input, text area, checkbox, password, radio...

4 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.

HTML Id Attribute

The HTML id attribute represents the unique identifier for an element of the HTML document. Each element has its unique identifier. The id attribute is a global attribute that can be...

12 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

HTML <section> tag

The section element in HTML is used to define sections in a document. Syntax of Section Tag: <body> <h1>……….</h1> <section> <h2>……….</h2> <p> …………………………</p> </section> <section> <h2>………..</h2> <p>…………………………. <p> </section> </body> Examples of Section Tag Example 1: In this example, we use the HTML "section" element...

3 minutes read.

HTML Charsets

In this tutorial, we are going to discuss about the charsets in the HTML. The letters, numbers, and several other symbols are shown correctly by the web browser. All of this...

2 minutes read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.