如何在 HTML 中包含錨點?
在本文中,我們將執行如何在 HTML 中包含錨點的任務。讓我們深入瞭解本文,以瞭解更多關於 HTML 中錨點的資訊。
錨元素用於將源錨點連結到目標錨點。目標是源錨點連線到的資源,而源是指向另一個站點的文字、圖片或按鈕。
超連結是使網際網路成為資訊高速公路的關鍵技術之一。
為了更好地理解如何在 HTML 中包含錨點,讓我們看看以下示例
示例 1
在下面的示例中,我們正在建立一個**跳轉錨點**連結。
<!DOCTYPE html>
<html>
<head>
<style>
.main-content {
height: 90vh;
text-align: justify;
}
</style>
</head>
<body>
<h2 id="tutorials">Tutorials Point</h2>
<p class="main-content">
Tutorials Point originated from the idea that there exists a class of readers who
respond better to online content and prefer to learn new skills at their own pace
from the comforts of their drawing rooms.The journey commenced with a single tutorial
on HTML in 2006 and elated by the response it generated, we worked our way to adding
fresh tutorials to our repository which now proudly flaunts a wealth of tutorials and
allied articles on topics ranging from programming languages to web designing to academics
and much more.</p>
<p>Click To
<a href="#tutorials">Jump</a>.
</p>
</body>
</html>
執行上述指令碼後,輸出視窗彈出,顯示上述指令碼中使用的文字以及提到的錨點標籤“**點選跳轉**”,使用者按下時可以跳轉到頁面開頭。
示例 2
考慮到以下內容,我們正在建立一個從另一個網頁連結到錨點的示例。
<!DOCTYPE html>
<html>
<body>
<h2 id="Tutorials">TutorialsPoint</h2>
<p>Tutorials Point originated from the idea that there exists a class of readers
who respond better to online content and preferto learn new skills at their own
place from the comforts of their drawing rooms.</p>
<p>
<a href="https://tutorialspoint.tw/market/index.asp">Go To The Course Page.</a>
</p>
<p>
<a href="https://tutorialspoint.tw/latest/ebooks">Search For Ebooks.</a>
</p>
</body>
</html>
當指令碼執行時,它將生成一個輸出,顯示上述指令碼中使用的文字以及使用錨點標籤附加到網頁的連結。當用戶點選連結時,它將開啟新頁面。
示例 3:使用 JavaScript
檢視以下示例,我們正在建立一個到 javascript 的連結。
<!DOCTYPE html>
<html>
<body>
<a href="javascript:alert('Welcome To TutorialsPoint!');">Click To Execute</a>
</body>
</html>
當給定指令碼執行時,它將提供一個輸出,其中包含使用帶有文字“**點選執行**”的錨點放置在網頁上的連結。
如果使用者點選連結,指令碼將被觸發並顯示警報“歡迎來到 tutorials point”。
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP