The Wayback Machine - https://web.archive.org/web/20240914101729/https://www.geeksforgeeks.org/html-links/
Open In App

HTML Links Hyperlinks

Last Updated : 06 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HTML links, or hyperlinks, connect web pages and are created using the `<a>` tag with the `href` attribute. They enable users to navigate between pages or resources. Links can be text, images, or other elements, enhancing web navigation and interactivity. Users can click on links to navigate between different pages or resources.

Note: A hyperlink can be represented by an image or any other HTML element, not just text.

By default, links will appear as follows in all browsers:

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

Syntax

<a href="url">link text</a>

Target Attribute

AttributeDescription
_blankOpens the linked document in a new window or tab.
_selfOpens the linked document in the same frame or window as the link. (Default behavior)
_parentOpens the linked document in the parent frame.
_topOpens the linked document in the full body of the window.
framenameOpens the linked document in a specified frame. The frame’s name is specified in the attribute.

HTML Links Examples

Example 1: Basic Hyperlink

In this example we contains a paragraph instructing users to click on the link labeled “GeeksforGeeks,” which directs to the website “https://www.geeksforgeeks.org”.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>HTML Links</title>
</head>

<body>
    <p>Click on the following link</p>
    <a href="https://www.geeksforgeeks.org">
        GeeksforGeeks
    </a>
</body>

</html>

Output:

Example 2: Using target Attributes

In this example we demonstrates the use of target attributes in links. Each link opens in a different context: _blank opens in a new window or tab, _self in the same frame, _parent in the parent frame, _top in the full window body, and framename in a specified frame.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>Target Attribute Example</title>
</head>

<body>
    <h3>
        Various options available in the
        Target Attribute
    </h3>

    <p>
        If you set the target attribute to
        "_blank", the link will open in a new
        browser window or tab.
    </p>
    <a href="https://www.geeksforgeeks.org" 
       target="_blank">
        GeeksforGeeks
    </a>

    <p>
        If you set the target attribute to
        "_self", the link will open in the
        same window or tab.
    </p>
    <a href="https://www.geeksforgeeks.org" 
       target="_self">
        GeeksforGeeks
    </a>

    <p>
        If you set the target attribute to
        "_top", the link will open in the full
        body of the window.
    </p>
    <a href="https://www.geeksforgeeks.org" 
       target="_top">
        GeeksforGeeks
    </a>

    <p>
        If you set the target attribute to
        "_parent", the link will open in the
        parent frame.
    </p>
    <a href="https://www.geeksforgeeks.org" 
       target="_parent">
        GeeksforGeeks
    </a>
</body>

</html>

Output: 

Supported Browsers

HTML Links Hyperlinks – FAQs

What is an HTML hyperlink?

An HTML hyperlink is created using the <a> tag to link to other web pages, files, locations within the same page, email addresses, or any URL.

How to create a basic hyperlink in HTML?

Use the <a> tag with the href attribute. Example: <a href=”https://example.com”>Visit Example</a>

How to open a link in a new tab or window?

Add the target=”_blank” attribute to the <a> tag. Example: <a href=”https://example.com” target=”_blank”>Visit Example</a>

How to add link to an email address?

Use the mailto: scheme in the href attribute. Example: <a href=”mailto:someone@example.com”>Email Us</a>

Can hyperlinks be styled with CSS?

Yes, hyperlinks can be styled using CSS with pseudo-classes like :link, :visited, :hover, and :active. Example: a { color: green; } a:hover { color: blue; }



Previous Article
Next Article

Similar Reads

Difference between normal links and active links
Websites are designed to point you to different resources. You can move from one website to another through links. Links help you to get information from different resources. Links are established in simple HTML web pages through &lt;a&gt; tag.Links are categorized into three types. Typically a Link is displayed in three different colors based on t
2 min read
How to overrule underlining Hyperlinks ?
In CSS, the hyperlinks are underlined by default. This is due to the default decoration that is imposed by HTML/CSS. To get rid of this underline, we need to do the following changes in the default decoration of the anchor tag using CSS. We can get rid of underlying hyperlinks by using CSS text-decoration property. If this property is set to none t
1 min read
HTML DOM links Collection
The DOM links collection is used to return the collection of all &lt;a&gt; and &lt;area&gt; elements with the "href" attribute in the HTML document. The elements in the collection are sorted as they appear in the sourcecode. Syntax: document.links Properties: It contains a single property length which is used to return the number of &lt;a&gt; and
4 min read
How to disable HTML links using JavaScript / jQuery ?
Given an HTML link and the task is to disable the link by using JavaScript/jQuery. Approach 1: Disable HTML link using JavaScript using setAttribute() Method. JavaScript setAttribute() Method: This method adds the defined attribute to an element and gives it to the passed value. In case of the specified attribute already exists, the value is set/ch
5 min read
How to create Right Aligned Menu Links using HTML and CSS ?
The right-aligned menu links are used on many websites. Like hotels website that contains lots of options in the menu section but in case of emergency to make contact with them need specific attention. In that case, you can put all the menu options on the left side of the navigation bar and display contact us option on the right side of the bar. Th
3 min read
How to create animated banner links using HTML and CSS?
Links are one of the most important parts of any component that is used in website making. Almost every component had some form of links in it. A common example is a menu/nav-bar. All we see is some button like home, about, etc. but under the hood they all are links. Sometimes there comes a situation where you don't want to wrap the link inside a b
2 min read
How to Create Links to Other Pages in HTML ?
HTML links are like pathways on the internet. They connect one webpage to another. Imagine a link as having two parts: a starting point (where you click) and an endpoint (where you end up). When you click on a link, you're basically starting at one point (the anchor) and moving to another (the destination). These links are made using anchor tags in
2 min read
How to Add Skip Navigation Links for Better Web Accessibility in HTML?
Adding skip navigation links in HTML is an essential practice for enhancing web accessibility. These links allow users to bypass repetitive navigation menus and directly access the main content of a webpage, especially for screen reader users or keyboard-only users. This simple addition significantly improves the usability and accessibility of a we
7 min read
How to Find & Add Nofollow Links to your Website in HTML ?
The nofollow attribute in links is a crucial tool for controlling how search engine crawlers interact with your website's content. By adding the nofollow attribute to specific links, you instruct search engine bots not to follow those links, preventing them from spreading content to linked pages. This helps control spam and can improve your website
2 min read
How to create links to sections within the same page in HTML ?
We will explore how to create links within an HTML page that are linked to specific sections of the same page. Creating internal links in HTML enhances user experience by making navigation easier for website visitors. By using the id attribute and the &lt;a&gt; (anchor) tag, you can link to specific sections of a webpage, allowing quick access to n
2 min read
How to use anchor tag to open links in HTML ?
In this article, we will learn how to use anchor tags to open links in HTML and we will implement different operations using anchor tags in HTML. We will see in this article, how to redirect another website through an anchor tag and how to open a blank new tag for any new link to open an image in a new tag, and how to open the image on the same pag
3 min read
How to set cursor style to pointer for links without href ?
Method 1: Using a CSS class for the links A CSS class is created that changes the cursor property. The cursor property is used to specify the mouse cursor to be displayed when the mouse is pointed over an element. Using the 'pointer' value in this property will change the cursor to a 'pointer' indicating a link. This class can then be used on any l
2 min read
How to Create Navigation Links using HTML5 ?
In this article, we create a navigation link by using the &lt;nav&gt; tag in the document. The nav element represents a section of the page whose purpose is to provide navigational links, either in the current document or to other documents. The links in the "nav" element may point to other webpages or to different sections of the same webpage. It
1 min read
Express.js res.links() Function
The res.links() function is used to join the links provided as properties of the parameter to populate the response’s Link HTTP header field. Syntax: res.links( links ) Parameter: The link parameter describes the name of the link to be joined. Return Value: It returns an Object. Installation of the express module: You can visit the link to Install
2 min read
Primer CSS Marketing Links
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, an
2 min read
D3.js node.links() Function
The node.links() function returns an array of links to the children of the node object, each link object has a source and a target field that hold references to child nodes. Syntax: node.links(); Parameters: This method does not accept any parameters. Return Values: This method returns an array of links to the children of the node object. Example 1
1 min read
How to Display the file format of links using CSS ?
In this article, we will explain the approach to display the file formats on a webpage. Many times while browsing, we need to download a document file but in PDF format, however, a problem might occur that multiple links of downloading the file are there, but each link contains different file formats. One may contain a document file and another may
2 min read
How to find all links with an hreflang attribute using jQuery ?
In this article, we will learn to find all links with a hreflang attribute. The hreflang is an attribute that tells search engines the relationship between pages in different languages on your website. To find all links with an hreflang attribute using jQuery, you can use the attribute selector $('[hreflang]'). This will select all elements that ha
2 min read
How to select all links inside the paragraph using jQuery ?
In this article, we will see how to write code to select all links inside the paragraph using jQuery. To select all links inside paragraph element, we use parent descendant selector. This selector is used to selects every element that are descendant to a specific (parent) element. Syntax: $("parent descendant") Approach: Here, we have created links
1 min read
How to customize links for pagination in Bootstrap ?
In many websites, we notice that when we search for something then all the related content is shown but if the number of content is large then it will make the website longer. To solve this, there is pagination in the webpage i.e, the contents are divided into many pages and on clicking the user can navigate through the related contents. Note: Pagi
4 min read
Bootstrap 5 Cards Titles, text, and links
Cards Titles, text, and links are used to add a title, text content, and links to a card. The .card-title class is used with &lt;h*&gt; tag to create the card title and the .card-subtitle class is used with &lt;h*&gt; tag to create the card subtitle. Similarly, the .card-link class is used with &lt;a&gt; tag to create a card link. Cards Titles, tex
2 min read
D3.js Shapes Links API Complete Reference
The D3 is an abbreviation of Data-Driven Documents, and D3.js is a resource JavaScript library for managing documents based on data. D3 is one of the most effective frameworks to work on data visualization. Shapes Links: D3.js linkVertical() FunctionD3.js linkHorizontal() FunctionD3.js link() FunctionD3.js link.source() FunctionD3.js link.target()
1 min read
How to style a href links in React using Tailwind CSS ?
In this article, we will learn how we can style a href link in Reactjs. Since we use Tailwind CSS, Tailwind CSS describes itself as the first applicable CSS framework. Rather than focusing on the performance of a style object, Tailwind focuses on how it should be displayed. This makes it easier for the developer to explore new styles and transform
2 min read
Foundation CSS Base Typography Links
Foundation CSS is an open-source &amp; responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails to look amazing &amp; can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is b
3 min read
Blaze UI Typography Hyper-links
Blaze UI is an open-source CSS-based UI library that provides a great structure for building websites quickly with a scalable and maintainable foundation. In this article, we will learn about Blazer UI Typography Hyper-links. Blazer UI Typography Hyper-links are used to provide some styling to hyperlinks i.e providing different colors to the links.
2 min read
Primer CSS Links
Primer CSS is a free and open-source CSS framework. It is built upon the systems that create the foundation of the basic style elements such as spacing, typography, and colour. Created with GitHub’s design system, it is highly reusable and flexible. Primer CSS Links are used to decorate links in the webpage. Primer CSS has lots of customizations fo
3 min read
Tachyons Element Links
Tachyon is a toolkit that is used to make a responsive website. In this article, we will learn about how to insert a clickable link using the Tachyons toolkit. Links are used to specifying the relationship between the current document and an external resource. Tachyons Element Links Classes: link underline blue hover-orange: This class is used to p
3 min read
React.js Blueprint Typography Links
BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications. Typography is used to present content efficiently. Links are used to redirect users from one page to another. Typography Links has no special class to provide Blueprint styles.
2 min read
Bootstrap 5 Colored links
Bootstrap 5 Colored links are used to add colors to the link element. To set the colored links, we use the classes of utilities built on our theme colors. To make different color links, we will use .link-* class and add CSS styles to it. Colored links used Classes: link-primary: This class is used to set the primary color of the link element.link-s
2 min read
Explain the Typography and links in Bootstrap?
In this article, we will see the Typography &amp; the Links In Bootstrap, along with understanding their basic implementation through the examples. Bootstrap Typography facilitates the different styling and formatting of text content, along with providing customization which includes customized headings, inline subheadings, lists, and paragraphs, a
2 min read