HTML Links

Code Bacha
0
HTML Links - codeBacha

HTML Links

Links are an essential part of the web, allowing users to navigate between pages or resources. In HTML, links are created using the <a> tag, which stands for "anchor."

1. Basic Syntax of the <a> Tag

The basic structure of a hyperlink is as follows:

        <a href="URL">Link Text</a>
    

Here:

  • href: Specifies the URL the link points to.
  • Link Text: The clickable text visible to the user.

2. Adding Hyperlinks

To add a link to a webpage, use the href attribute in the <a> tag. Example:

        <a href="https://codebacha.blogspot.com/">Visit codeBacha</a>
    

Output: Visit codeBacha

3. Linking to Other Pages

You can link to other pages within your website by providing a relative URL:

        <a href="about.html">About Us</a>
    

Output: About Us

4. Opening Links in a New Tab

Use the target attribute with the value _blank to open the link in a new tab:

        <a href="https://codebacha.blogspot.com/" target="_blank">Visit codeBacha in a new tab</a>
    

Output: Visit codeBacha in a new tab

5. Linking to an Email Address

To create an email link, use the mailto: prefix in the href attribute:

        <a href="mailto:example@example.com">Email Us</a>
    

Output: Email Us

6. Linking to a Phone Number

To create a clickable phone number link, use the tel: prefix:

        <a href="tel:+1234567890">Call Us</a>
    

Output: Call Us

7. Practical Example

Here’s a complete example combining different types of links:

        <p>Explore our resources:</p>
        <ul>
            <li><a href="https://codebacha.blogspot.com/">Blog</a></li>
            <li><a href="contact.html">Contact Us</a></li>
            <li><a href="mailto:info@codebacha.com">Email Us</a></li>
        </ul>
    

Output:

Explore our resources:

Written By: Muhammad Shoaib Khan Marwat (MSKM) | https://codebacha.blogspot.com/
Tags

Post a Comment

0Comments

Post a Comment (0)