Friday, December 20, 2024

HTML Links

 HTML links are created using the <a> (anchor) tag. Here is the basic structure:

<a href="URL">Link Text</a>
  • href: This attribute specifies the destination URL (the link target).
  • Link Text: This is the clickable text that the user will see and click.

Example 1: A simple link to an external website

<a href="https://www.example.com">Click here to visit Example</a>

Example 2: A link to a different section on the same page (anchor link)

<a href="#section1">Go to Section 1</a>
<h2 id="section1">Section 1</h2>

Example 3: A link that opens in a new tab

<a href="https://www.example.com" target="_blank">Visit Example</a>
  • The target="_blank" attribute ensures that the link opens in a new tab.

Example 4: A mailto link

<a href="mailto:someone@example.com">Send an Email</a>

Example 5: A phone link

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

Let me know if you need further examples or explanations!

No comments:

Post a Comment

How can you refer to a CSS file in a web page?

 To refer to a CSS file in a web page, you use the <link> element inside the <head> section of the HTML document. Here's t...