Learn how to create hyperlinks using the <a> tag to connect different pages, websites, email addresses, and more.
To create an HTML webpage that demonstrates how to create hyperlinks using the <a> (anchor) tag with various types of links.
Hyperlinks are the backbone of the web. The <a> tag is used to create links. You can create:
mailto:tel:| Type | Description | Example Code |
|---|---|---|
| External Link | Links to another website | <a href="https://google.com">Google</a> |
| Internal Link | Links to another page on your site | <a href="page2.html">Page 2</a> |
| Anchor Link | Links to a section within the same page | <a href="#section1">Section 1</a> |
| Email Link | Opens default email client | <a href="mailto:info@example.com">Email</a> |
| Phone Link | Dials a phone number (mobile) | <a href="tel:+923001234567">Call Us</a> |
| Image Link | An image that acts as a link | <a href="page.html"><img src="img.jpg"></a> |
| Download Link | Downloads the linked file | <a href="file.pdf" download>Download</a> |
target Attribute Values| Value | Description | When to Use |
|---|---|---|
_blank |
Opens in a new tab or window | External links (recommended) |
_self |
Opens in the same tab (default) | Internal links |
_parent |
Opens in the parent frame | For framed pages |
_top |
Opens in the full window | For framed pages |
| Mistake | Why It's Wrong | Correct Way |
|---|---|---|
Missing href attribute |
Link won't work | Always include href |
Forgetting http:// or https:// |
Link may try to open as a local file | Use full URL: https://google.com |
Using spaces in href values |
Invalid URL | Use %20 or no spaces |
Not using target="_blank" for external links |
User leaves your site | Use target="_blank" for external links |
Forgetting to close <a> tag |
Invalid HTML | Always close with </a> |
| Using "click here" as link text | Poor accessibility and SEO | Use descriptive link text |
<a> is the anchor tag used for creating hyperlinks.href attribute is required for the link to work.target="_blank" for external links to open in a new tab.title provides a helpful tooltip on hover.#id) allow navigation within the same page.You have successfully:
href, target, and title attributes.href attribute for links. Use target="_blank" for external links to keep users on your site. Use descriptive link text (not "click here") for better accessibility and SEO.
ایک HTML ویب صفحہ بنانا جو ہائپر لنکس بنانے کا طریقہ <a> (اینکر) ٹیگ کے ساتھ مختلف اقسام کے لنکس کا استعمال کرتے ہوئے ظاہر کرتا ہے۔
ہائپر لنکس ویب کی ریڑھ کی ہڈی ہیں۔ <a> ٹیگ لنکس بنانے کے لیے استعمال ہوتا ہے۔ آپ بنا سکتے ہیں:
mailto: کا استعمال کرتے ہوئےtel: کا استعمال کرتے ہوئے| قسم | وضاحت | کوڈ کی مثال |
|---|---|---|
| بیرونی لنک | کسی اور ویب سائٹ کا لنک | <a href="https://google.com">Google</a> |
| اندرونی لنک | آپ کی سائٹ کے کسی اور صفحے کا لنک | <a href="page2.html">صفحہ 2</a> |
| اینکر لنک | اسی صفحے کے کسی حصے کا لنک | <a href="#section1">سیکشن 1</a> |
| ای میل لنک | ڈیفالٹ ای میل کلائنٹ کھولتا ہے | <a href="mailto:info@example.com">Email</a> |
| فون لنک | فون نمبر ڈائل کرتا ہے (موبائل) | <a href="tel:+923001234567">Call Us</a> |
| تصویری لنک | ایک تصویر جو لنک کا کام کرتی ہے | <a href="page.html"><img src="img.jpg"></a> |
| ڈاؤن لوڈ لنک | لنک شدہ فائل ڈاؤن لوڈ کرتا ہے | <a href="file.pdf" download>Download</a> |
target صفت کی اقدار| قدر | وضاحت | کب استعمال کریں |
|---|---|---|
_blank |
نئی ٹیب یا ونڈو میں کھلتا ہے | بیرونی لنکس (تجویز کردہ) |
_self |
اسی ٹیب میں کھلتا ہے (ڈیفالٹ) | اندرونی لنکس |
_parent |
پیرنٹ فریم میں کھلتا ہے | فریم شدہ صفحات کے لیے |
_top |
پوری ونڈو میں کھلتا ہے | فریم شدہ صفحات کے لیے |
| غلطی | یہ کیوں غلط ہے | صحیح طریقہ |
|---|---|---|
href صفت غائب |
لنک کام نہیں کرے گا | ہمیشہ href شامل کریں |
http:// یا https:// بھول جانا |
لنک مقامی فائل کے طور پر کھلنے کی کوشش کر سکتا ہے | مکمل URL استعمال کریں: https://google.com |
href اقدار میں اسپیس کا استعمال |
غلط URL | %20 استعمال کریں یا اسپیس نہ استعمال کریں |
بیرونی لنکس کے لیے target="_blank" کا استعمال نہ کرنا |
صارف آپ کی سائٹ چھوڑ دیتا ہے | بیرونی لنکس کے لیے target="_blank" استعمال کریں |
<a> ٹیگ بند کرنا بھول جانا |
غلط HTML | ہمیشہ </a> کے ساتھ بند کریں |
| "click here" کو لنک ٹیکسٹ کے طور پر استعمال کرنا | خراب رسائی اور SEO | وضاحتی لنک ٹیکسٹ استعمال کریں |
<a> ہائپر لنکس بنانے کے لیے استعمال ہونے والا اینکر ٹیگ ہے۔href صفت لنک کے کام کرنے کے لیے ضروری ہے۔target="_blank" استعمال کریں تاکہ نئی ٹیب میں کھلے۔title ہوور پر مددگار ٹولٹپ فراہم کرتا ہے۔#id) اسی صفحے کے اندر نیویگیشن کی اجازت دیتے ہیں۔آپ نے کامیابی سے:
href، target، اور title صفات کا استعمال کیا۔href صفت شامل کریں۔ صارفین کو آپ کی سائٹ پر رکھنے کے لیے بیرونی لنکس کے لیے target="_blank" استعمال کریں۔ بہتر رسائی اور SEO کے لیے وضاحتی لنک ٹیکسٹ استعمال کریں ("یہاں کلک کریں" کے بجائے)۔