首頁  >  文章  >  web前端  >  HTML 中的錨點

HTML 中的錨點

王林
王林原創
2024-09-04 16:38:46364瀏覽

HTML 錨標記是 HTML 中最重要的元素之一,用於在網站之間導航、從一個頁面移動到另一個頁面、點擊滑鼠開啟某種圖像或文字。它用於定義所包含的超連結的開頭和結尾。大多數情況下,搜尋引擎使用它來定義目標 URL。它內容豐富,並且與登陸頁面更相關。

這些連結在不同的場景中代表不同的意義,例如

  • 帶下劃線且紅色的連結表示活動連結
  • 帶下劃線且紫色的連結表示已訪問過的連結。
  • 帶有下劃線和藍色的連結表示未造訪的連結。

文法:

讓我們來看看定義 的實際語法標籤。

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

如上所示,語法;包含主要部分連結的標籤,定義如下:

HTML 中的錨點

1。 href 屬性

該屬性用於定義超鏈接,其中的目標地址大家可能很熟悉。超連結可作為網頁文件和目標連結之間的連接器。

  2. 名稱屬性

中的name屬性標籤用於前往頁面的特定點。

  • It’s most useful for defining large pages or to define subdivisions.
  • Example:Homepage So in this example we are adding #tag at the anchor name. it’s helpful to the browser to find or jump to the defined location like home. #name can be placed after the filename.

  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。

以上是HTML 中的錨點的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn