logo CBCE Skill INDIA

Welcome to CBCE Skill INDIA. An ISO 9001:2015 Certified Autonomous Body | Best Quality Computer and Skills Training Provider Organization. Established Under Indian Trust Act 1882, Govt. of India. Identity No. - IV-190200628, and registered under NITI Aayog Govt. of India. Identity No. - WB/2023/0344555. Also registered under Ministry of Micro, Small & Medium Enterprises - MSME (Govt. of India). Registration Number - UDYAM-WB-06-0031863

HTML Anchor


HTML Anchor

  • In HTML, an anchor, also known as a hyperlink, is an element used to create a link to another web page, file, or resource. It allows users to navigate between different pages on the same website or to external websites. The anchor is represented by the <a> tag, and it uses the href attribute to specify the URL or destination of the link.

 

Here's the basic syntax for creating an anchor in HTML:

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

Where:

href: This attribute specifies the destination URL or location that the link will point to. It can be an absolute URL (e.g., "https://www.example.com") or a relative URL (e.g., "about.html" or "images/pic.jpg"). When clicked, the user will be redirected to the URL specified in the href attribute.

Link Text: This is the text or content that will be displayed on the web page as the clickable link. When a user clicks on this text, they will be taken to the specified destination.

Example 1: Link to an external website:

<a href="https://www.example.com">Visit Example Website</a>

 

Example 2: Link to a page within the same website using a relative URL:

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

Example 3: Link to an email address using the "mailto" protocol:

<a href="mailto:[email protected]">Contact Us</a>

You can also use anchors with other HTML elements, such as images, to create linked images:

<a href="https://www.example.com">
  <img src="path/to/image.jpg" alt="Image description">
</a>

When the user clicks on the image, they will be redirected to the URL specified in the href attribute.

It's important to ensure that the destination URLs are valid and that the links work correctly. Also, consider adding the target="_blank" attribute to open external links in a new browser tab, providing a better user experience and keeping your website accessible to users even when they visit external pages.

Thank You

Popular Post:

Give us your feedback!

Your email address will not be published. Required fields are marked *
0 Comments Write Comment