Lesson
HyperLink Tag
Completion requirements
Hyperlink Tag
Hyperlink Tag in HTML
The hyperlink tag (<a>) is used to create
clickable links to other web pages, documents, or resources.
Basic syntax:
<a href="URL">Link Text</a>
- href → specifies the URL (absolute or relative)
- Link Text → the clickable text visible to users
Example
<!DOCTYPE html> <html> <head> <title>Hyperlinks</title> </head> <body> <h1>About page</h1> <a href="https://www.geeksforgeeks.org/">Click Me</a> </body> </html>
Types of Hyperlinks
- Absolute → full URL (e.g., https://example.com/page.html)
- Relative → relative to current page (e.g., ./about.html)
-
Internal Links → jump to a section in the same page
(using
#id)
Example with Absolute, Relative, and Internal Links
<a href="https://www.mait.ac.in/">External Link</a> <a href="/course">Relative Link</a> <a href="#section2">Jump to Section 2</a> <h2 id="section1">Section 1</h2> <p>This is section 1 content.</p>
Target Attribute
The target attribute defines where the link opens:
- _self → opens in the same tab (default)
- _blank → opens in a new tab/window
- _parent → opens in the parent frame
- _top → opens in the full body of the window
Example of Target Attribute
<a href="https://example.com" target="_self">Same Tab</a> <a href="https://example.com" target="_blank">New Tab</a> <a href="https://example.com" target="_parent">Parent Frame</a> <a href="https://example.com" target="_top">Top Frame</a>