Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
How to create a nofollow link using HTML5 ?
Next article icon

How to Create a Hyperlink in HTML?

Last Updated : 23 Nov, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

If we want to navigate from one page to another then Hyperlink comes into play. It provides you the link to navigate to another page, on hovering that link the cursor turns into a little hand. Hyperlink enables us to connect one page to another, navigate to specific sections, or even open applications through a web address. Almost any content can become a link, making it simple for users to move to different parts of the web with a click.

1. Using <a>Tag

In this approach, we are using the <a> (anchor) tag to create a hyperlink. The href attribute within the <a> tag specifies the destination URL, allowing users to navigate to different sites.

Syntax

<a href = "link" target ="_blank"> Link Name </a>

Example: When users click on the "Visit GeeksforGeeks" link, they will be directed to the GeeksforGeeks website in a new tab (due to the target="_blank" attribute).

HTML
<a href="https://www.geeksforgeeks.org/" target="_blank">     Visit GeeksforGeeks </a> 

Output

hyperlink_output
Output

2. Using HTML DOM Window.location Property

Another method for creating hyperlinks is to use the HTML DOM window.location property to dynamically set the browser's current location. By assigning a URL to window.location.href, we can trigger a redirection, providing hyperlink-like functionality.

Syntax

window.location.href='link'

Example: When users click the "Visit GeeksforGeeks" button, they will be redirected to the GeeksforGeeks website.

HTML
<button onclick= "window.location.href='https://www.geeksforgeeks.org/'"> 	Visit GeeksforGeeks </button> 

Output

output1

Next Article
How to create a nofollow link using HTML5 ?

G

gauravggeeksforgeeks
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-Questions

Similar Reads

  • How to Create Mail and Phone Link in HTML?
    The HTML provides mailto and tel attributes to create the mail and phone links. We can use them in href to create the links. The href provides other sub-attributes that define the other properties of the mailto and phone link. Creating a Mailto LinkA mailto link is an easy way for users to contact w
    2 min read
  • How to Create a Download Link in HTML?
    A download link allows users to download a specific file when they click on it. The download attribute in HTML is used to create a download link. Using the anchor tag we can create a download link in the HTML. Using the <a> Anchor TagTo create a download link in HTML, use the <a> tag wit
    1 min read
  • How to Create a Bookmark Link in HTML ?
    Bookmark Link is used for the users to navigate directly to the specific sections within the web application. We can create this bookmark link functionality in HTML using the id attribute with JavaScript and the class attribute with jQuery. Below are the approaches to create a bookmark link in HTML:
    5 min read
  • How to create a nofollow link using HTML5 ?
    A nofollow link s used by Google to specify that the Google search spider should not follow that link and mostly used for paid links. Nofollow links are links with a rel=”nofollow” HTML tag applied to them. The nofollow tag tells search engines to ignore that link. The nofollow links do not pass Pag
    1 min read
  • How to Create Table in HTML?
    HTML tables are used for organizing and displaying data in a structured format on web pages. Tables are commonly used for product information, presenting data analytics, or designing a pricing comparison chart. Elements of HTML TableTable Elements Description <table> The <table> element
    4 min read
  • How to Create a Link to Send Email in HTML ?
    Incorporating email links into HTML pages facilitates a smooth way for users to send a message directly from the webpage. We will see how to create these email links, making your web pages user-friendly and interactive. Table of Content Using Mailto Protocol with Predefined SubjectCreating Link to s
    2 min read
  • How to Create a Hyperlink Component in MATLAB?
    MATLAB is a matrix-based computational environment that has its own programming language which is very easy to use and learn. It is used for heavy mathematical concepts, understanding huge data sets with the help of the GUI Graphical User Interface of MATLAB.   In GUIs, hyperlinked text labels are f
    4 min read
  • How to Create an index.html File?
    Creating an index.html file is a fundamental step in HTML programming and website development. This file serves as the backbone of a basic HTML webpage. In this article, we will explore four straightforward methods to create an index.html file, which is important for building and serving web content
    3 min read
  • How to Add a Hyperlink in MS Word
    Adding clickable links to your document is a simple yet powerful way to connect readers to external websites, email addresses, or even other sections within the same file. Knowing how to add a hyperlink in MS Word allows you to enhance your content and improve navigation for your audience. Whether y
    3 min read
  • How to Create Navigation Links using HTML5 ?
    In this article, we create a navigation link by using the <nav> 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
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences