Anchor in HTML

王林
Release: 2024-09-04 16:38:46
Original
405 people have browsed it

HTML anchor tag is one of the most important elements in HTML used for navigating between websites, moving from one page to another, mouse click to open some kind of image or text. It’s used to define the starting and end of the included hyperlink. Mostly this is used by the search engine to define destination URL. It’s informative and works as more relevant to the landing page.

Those links represent different meanings in a different scenario like

  • Link with underline and red in color shows an active link
  • Link with underline and purple in color shows visited link.
  • Link with underline and blue in color shows an unvisited link.

Syntax:

Let’s see actual syntax for defining tag.

<a href="Link_URL">Link Home</a>
Copy after login

As shown above, syntax tag containing a link with major parts as defined below:

Anchor in HTML

1. href attribute

This attribute is used to define hyperlink, in which one may familiar with its destination address. Hyperlink work as a connector in between your web page document and target link.

  2. Name attribute

The name attribute in tag is used to go at a specific point to the page.

  3. Target attribute

  • The target attribute is used to define the destination page or the defined target page may be opened.
  • It’s used as a common option that is used by target attributes to link with other pages.
  • If the target attribute defines with a blank value like “target=_blank” then it will open a new tab at the target location.

4. Title Attribute

  • The title attribute is one of the important attributes used to give special attention where one can easily move when they click the link.
  • If the user moves the mouse pointer onto the link reference, the title text which was given into the attribute point will be shown there.
  • It works like a tooltip or details where the link will navigate. This approach makes webpages or documents more user-friendly.

Working of Anchor in HTML

Examples

Here we are going to show some examples having use of actual tag.

1. HTML code

<h4>Examples for Anchor in HTML </h4>
<a href="https://timesofindia.indiatimes.com/">Latest News </a><br><br>
<a href="HTMLcolor.html">Navigate on other File</a><br>
Copy after login

Output:
 Anchor in HTML

On clicking the latest news, the output is :Anchor in HTML

 By clicking on the link Navigate on other File” it will show another webpage as:
Anchor in HTML

2. HTML Code

<h2>Reach to EDUCBA </h2>
<ul>
<li><a href="https://www.educba.com/">Website</a></li>
<li><a href="mailto:[email&#160;protected]">Email US</a></li>
<li><a href="tel:+123456789">Phone</a></li>
</ul>
Copy after login

 Output :

Anchor in HTML

The output shows some links, and that those links are in blue they are unvisited, the link showing in purple has visited the link and this is used to show the difference in links.

3. HTML Code

<h4>Image and File Demo</h4>
<p><a href="C:\Users\\Sonali\Desktop\jerry.jpeg">Image Demo</a> It will
open image</p>
<a href="./generate-zip?id=4" download="assets.zip">Download File</a>
Copy after login

Output :

Anchor in HTML

While clicking on image demo it will open the image as:Anchor in HTML

 While clicking on another link it will download the file as :Anchor in HTML

Conclusion- Anchor in HTML

Anchor tag in HTML is used to define a link that will navigate directly to the target location. It’s based on major components like hre attribute, name attribute, target attribute. tag is used for the internal and external links as well as for absolute and relative URL.

The above is the detailed content of Anchor in HTML. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template