ホームページ  >  記事  >  ウェブフロントエンド  >  HTMLのアンカー

HTMLのアンカー

王林
王林オリジナル
2024-09-04 16:38:46364ブラウズ

HTML アンカー タグは、Web サイト間の移動、あるページから別のページへの移動、マウスをクリックして何らかの画像やテキストを開くために使用される HTML の最も重要な要素の 1 つです。これは、含まれるハイパーリンクの開始と終了を定義するために使用されます。ほとんどの場合、これは検索エンジンが宛先 URL を定義するために使用します。これは有益であり、ランディング ページとの関連性がより高くなります。

これらのリンクは、

のような異なるシナリオで異なる意味を表します。
  • 下線と赤色のリンクはアクティブなリンクを示します
  • 下線と紫色のリンクは、訪問済みのリンクを示します。
  • 下線と青色のリンクは、未訪問のリンクを示します。

構文:

を定義するための実際の構文を見てみましょう。タグ。

<a href="Link_URL">Link Home</a>

上に示したように、構文 以下に定義されている主要部分へのリンクを含むタグ:

HTMLのアンカー

1. href 属性

この属性はハイパーリンクを定義するために使用され、宛先アドレスを知ることができます。ハイパーリンクは、Web ページのドキュメントとターゲット リンクの間のコネクタとして機能します。

2. 名前属性

の name 属性タグは、ページの特定のポイントに移動するために使用されます。

  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>

Output:
 HTMLのアンカー

On clicking the latest news, the output is :HTMLのアンカー

 By clicking on the link Navigate on other File” it will show another webpage as:
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>

 Output :

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>

Output :

HTMLのアンカー

While clicking on image demo it will open the image as:HTMLのアンカー

 While clicking on another link it will download the file as :HTMLのアンカー

結論 - HTML のアンカー

HTML のアンカー タグは、ターゲットの場所に直接移動するリンクを定義するために使用されます。これは、hre 属性、name 属性、target 属性などの主要コンポーネントに基づいています。タグは、内部リンクと外部リンク、および絶対 URL と相対 URL に使用されます。

以上がHTMLのアンカーの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。