HTML - web pages with hyperlinks (a tag explanation)

Sanmuqi 2022-05-14 14:37:08 阅读数:514

htmlwebpageshyperlinkstag

Preface : The last article briefly summarized HTML Basic labels used in , This article is a simple and in-depth summary a The attribute of the tag and its expression effect .

This article is from the first song HTML—— Text (educoder.net)


Catalog

a Tag attributes ——href attribute

href——anchor URL

href——relative URL

href——absolute URL

 href—— Email address

a Tag attributes ——target attribute  


In the last article , Mention that we can use <a> Tags define hyperlinks . for instance , A tag that can be transferred to Baidu web page .

<a href="https://baidu.com"> Baidu search </a>

This article simply summarizes a Properties of tags and their functions .

a Tag attributes ——href attribute

href Attributes are the most important attributes of hyperlinks , It is used to specify the target of the hyperlink URL.

A typical format for defining hyperlinks is as follows :

<a href="https://baidu.com"> Baidu search </a>

Among them, the hyperlink target is URL, There are three types

  • anchor URL (anchor URL): Point to a location on the same page ;

  • relative URL (relative URL): Point to different pages of the same website ;

  • absolute URL (absolute URL): Point to another website .

Different types of URL, There are different coding methods , Let's have a simple look .

href——anchor URL

for instance

The first 16 That's ok  <a href="#toc1"> brief introduction </a> Defined a point #toc1 Anchor link of the target , After clicking, it will be located to the 21 That's ok    <h2 id="toc1"> brief introduction </h2>  At the location shown

id The property value is toc1 The location of .

Besides , When href="#" when , Default back to the top of the page .

href——relative URL

for instance

<body>
<h2> Home page </h2>
<h3> Website navigation :</h3>
<ul>
<li><a href="./home.html"> Home page </a></li>
<li><a href="./blog.html"> Blog </a></li>
<li><a href="./project.html"> project </a></li>
<li><a href="./about.html"> About me </a></li>
</ul>
</body> 

  Compare different files in the same directory , use . In the current path .

href——absolute URL

This is easier to understand , Let's use the example at the beginning

<a href="https://baidu.com"> Baidu search </a> 

After clicking, it will jump to Baidu's page , This is absolute URL, It will jump to another website . 

 href—— Email address

We can also put href Property value set to mailto: Email address , In this way, you can call up the mailbox application , Send mail to the corresponding address .

<p> Send an email to :<a href="mailto:[email protected]">someone</a>

a Tag attributes ——target attribute  

target Property specifies where to open the hyperlink .

such as :

 <p><a href="https://en.wikipedia.org/wiki/HTML" target="_blank">HTML</a>

Means to open a link in a new browser window . 

target The value of               effect
target="_blank" or target="new" The link page appears in a new browser window
target="_self" The link page is displayed in the current window

 


Self summary :


 

Come on together !

版权声明:本文为[Sanmuqi]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/134/202205141431541791.html