×

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

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 <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.

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 Button Disabled

The HTML <button> element has many attributes, one of them is the disabled attribute. The button on which you apply the disabled attribute will not work, or we can say...

4 minutes read.

HTML5 Formatting

HTML Formatting HTML Formatting is a method of text formatting for a better appearance and look. HTML allows us to format text without using the CSS. HTML includes a lot of formatting tags....

6 minutes read.

Html &lt;dd> Tag

In an HTML description list, an item's definition or description is indicated using the definition description ("dd" tag). A <dd> tag can contain paragraphs, line breaks, images, links, and lists. It...

4 minutes read.

Responsive HTML5 and CSS3 Tutorial

Introduction to HTML5 Tutorial HTML5 is the latest and upgraded version of HTML. HTML is a hypertext markup language. Technically, it is not a programming language. It is a markup language. HTML...

17 minutes read.

HTML Headings

The titles and subtitles of our webpages are known as HTML headings. Let’s not talk about webpages but giving heading to almost everything like normal paragraphs, articles or let it...

2 minutes read.

HTML SVG

HTML SVG: SVG stands for Scalable Vector Graphics which defines the graphics for the web. It is a language for describing 2-D graphics in XML. Each drawn shape in SVG is...

1 minute read.

Div Tag in HTML

In HTML, ‘div’ is a tag that specifies division or section in HTML document. But before going in detail of it, let’s first understand about tags in HTML. The tag...

8 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 Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

HTML Font Color

The HTML <font> tag has an attribute called color, which defines the color of the text. We use the color attribute inside the <font> tag to specify the color of...

6 minutes read.

HTML Form Action

The <form> tag has an attribute named action that contains a URL. The HTML action attribute defines the webpage URL on which you want to send the data after submitting...

4 minutes read.

HTML Tutorial

Introduction This HTML tutorial helps beginners and professionals to learn HTML easily. HTML is a widely used web technology for website development. It stands for Hyper Text Markup Language. It is mainly used to...

7 minutes read.

HTML Data Tag

HTML Data Tag: The HTML < data > tag is used to transmit its content to a machine-readable version. The data are presented in a particular format. It is useful...

3 minutes read.

How to add Google Translate Button on your Webpage?

Google translator is a multi-language translator used for translating the webpage. Google develops it. In today's digital age, it is essential because information is available worldwide in some specific language...

5 minutes read.

How to add JavaScript to HTML

JavaScript is one of the most important languages today. It is a high-level, interpreted, lightweight programming language that makes web pages more interactive. It is a language of the web....

5 minutes read.

HTML <samp> tag

The Samp tag in HTML is used for defining the sample output from the computer program. This tag is a phrase type tag and a container tag that means the...

2 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.