如何在HTML頁面中使用href屬性?
href屬性指定連結指向的頁面的URL(href屬性指定連結的目標)。
我們應該將href屬性與<a>標籤一起使用,這樣它才會成為超連結。此<a>標籤應在<body>…</body>標籤內使用。
語法
以下是使用href屬性指定連結地址的<a>標籤的語法。
<a href="link address">link text</a>
示例
以下是在HTML頁面中使用href屬性的示例程式。
<!DOCTYPE html> <html> <body> <p><a href="https://www.Brave.com">Click this to navigate to the Brave home page</a></p> </body> </html>
如何連結同一頁面的某個部分?
我們可以使用以下語法連結同一頁面的某個部分。
語法
以下是連結同一網頁某個部分的語法。
<a href="#section id">heading of the section</a>
示例
以下是連結同一網頁某個部分的示例。
<!DOCTYPE html> <html> <body> <a href="#RAJYA SABHA">RAJYA SABHA</a> <h3>LOK SABHA</h3> <p>Lok Sabha is composed of representatives of the people chosen by direct election. <br> The maximum strength of the House of the Constitution is 552,<br> which is made up by election of upto 530 members to represent the States, <br> upto 20 members to represent the Union Territories and not more than two members of the <br> Anglo-Indian Community to be nominated by the Hon'ble President.</p> <h3 id="RAJYA SABHA">RAJYA SABHA</h3> <p>The ‘Council of States’ which is also known as Rajya Sabha,<br> a nomenclature that was announced by the chair in the House on the 23rd August, <br> 1954 has its own distinctive features.<br> The origin of the second Chamber can be traced to the Montague-Chelmsford Report of 1918. <br>The Government of India Act, <br>1919 provided for the creation of a ‘Council of State’ as a second chamber of the then legislature <br> with a restricted franchise which actually came into existence in 1921.<br> The Governor-General was the ex-officio President of the then Council of State. The Government of India Act,<br> 1935, hardly made any changes in its composition.</p> </body> </html>
當我們點選“Rajya sabha”時,它會跳轉到同一頁面上的“Rajya sabha”部分。
如何連結電話號碼?
我們可以使用以下語法連結電話號碼。
語法
以下是連結電話號碼的語法。
<a href="tel: phone number">phone number</a>
透過在href屬性中使用tel:,我們可以連結到電話號碼。
示例
以下是在網頁中連結電話號碼的示例程式。
<!DOCTYPE html> <html> <body> <p><a href="tel:9381276097">9381276097</a></p> </body> </html>
如何連結到郵件地址?
我們可以使用以下語法連結到郵件地址。
語法
以下是將郵件地址連結到網頁的語法。
<a href="mailto:xx@gmail.com">xx@gmail.com</a>
與連結手機號碼的方式相同。我們在href屬性中使用mailto代替tel。
示例
以下是在網頁中連結郵件地址的示例程式。
<!DOCTYPE html> <html> <body> <p><a href="mailto:lokeshnayak@gmail.com">lokeshnayak@gmail.com</a></p> </body> </html>
當我們點選電子郵件地址時,它會跳轉到我們系統中的預設郵件應用程式。
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP