HTML series (5): hyperlinks and html series hyperlinks
<A> a tag defines a hyperlink. The most important attribute is the href attribute, which indicates the target of the link. By setting different types of values for the href attribute, you can direct the link to different types of link addresses: internal link, external link, and anchor link.
Internal links refer to the links between the internal pages of a website with the same domain name, and external links refer to links from a webpage with a domain name to an external domain name website; an anchor link is a link that points to a domain name from outside a domain name with a text hyperlink. It is an important factor that affects the ranking of website keywords in search engines.
1. External hyperlink
<A href = "external page link address"> link text </a>
2. Relative Path
When the source file and the Referenced File are in the same directory, the file name is directly referenced .. /indicates the upper-level directory of the directory where the source file is located ,.. /.. /indicates the upper-level directory of the directory where the source file is located, and so on. reference the lower-level directory file and directly write the lower-level directory file names, separated.
3. Page hyperlinks
When a page is long and difficult to search, you can use hyperlinks in the page as a navigation bar. A hyperlink in a page is also called an anchor link. Similar to the bookmarkdoning function, a hyperlink can jump to different locations on the page. You do not need to drag the scroll bar repeatedly to locate the link.
Practice: use the name attribute of a to define the name of the anchor. Use the href attribute of a to jump to the corresponding anchor Based on the name.
Sample Code:
1 <body> 2 Use the name or id attribute?
In versions earlier than HTML 4.0, only the name attribute of the <a> tag can be used to create a fragment identifier. With the emergence of the id attribute in HTML 4.0, all HTML or XHTML elements can be fragment identifiers. This is because the id Identifier can be used in almost all tags. <A> the label retains the name attribute to be compatible with previous versions. You can also use the id attribute. These attributes can be exchanged and used, and the id attribute can be considered as an upgraded version of the name attribute. Both the name and id attributes can be used together with the href attribute, so that a <a> tag can be used as both a hyperlink and a fragment identifier.
You can simply regard the fragment identifier as an html simulation of the goto statement tags that are commonly used in many programming languages. The name attribute in the <a> tag, or the id attribute in the <a> or other tags will place an identifier in the document. When a tag is used to link to this document, it is equivalent to telling the browser to forward the tag to (goto.
The value of the id or name attribute can be any string caused by quotation marks. The string must be a unique tag and cannot be used repeatedly in other name or id attributes in the same document, but can be used again in different documents.
The name of the sample code above can be replaced with id.
Not complete ....................