English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML uses hyperlinks to connect to another document on the network. Links can be found almost in all web pages. Clicking on a link can jump from one page to another.
HTML Hyperlinks How to create hyperlinks in HTML documents.
!DOCTYPE html <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> </head> <body> <p> <a href="/index.html">This text</a> is a link to a page within this website.</p> <p><a href="https://www.baidu.com/">Baidu</a> is a link to a webpage on the World Wide Web.</p> </body> </html>Test and see ‹/›
HTML uses the <a> tag to set hyperlinks.
A hyperlink can be a single character, a word, or a group of words, or it can be an image. You can click on these contents to jump to a new document or a specific part of the current document.
When you move the mouse pointer over a link on a webpage, the arrow changes to a small hand.
The href attribute is used in the <a> tag to describe the address of the link.
By default, links will appear in the following form in the browser:
An unvisited link is displayed in blue font with an underline.
Visited links are displayed in purple with an underline.
When the link is clicked, it is displayed in red with an underline.
Note: If CSS styles are set for these hyperlinks, the display style will be displayed according to the CSS settings.
The HTML code for links is simple. It is similar to this:
<a href="https://www.oldtoolbag.com">Basic tutorial website</a>
The href attribute describes the target of the link.
<a href="https://www.oldtoolbag.com/">Access the basic tutorial website</a>
The following line is displayed as:Access the basic tutorial
Clicking this hyperlink will take the user to the homepage of the basic tutorial.
Tip: "Link text" does not have to be text. Images or other HTML elements can also be links.
Using the target attribute, you can define where the linked document is displayed.
The following line will open the document in a new window:
<a href="https://www.oldtoolbag.com/" target="_blank">Access the basic tutorial!/a>Test and see ‹/›
The id attribute can be used to create a bookmark tag in an HTML document.
Tip: Bookmarks are not displayed in any special way and are not displayed in HTML documents, so they are hidden from readers.
Insert an ID into an HTML document:
<a id="tips">Useful tips section</a>
Create a link to "useful tips section (id="tips"") in an HTML document:
<a href="#tips">Access the useful tips section</a>
Alternatively, create a link to "useful tips section (id="tips"}" from another page:
<a href="https://www.oldtoolbag.com/html/html-links.html#tips"> Access the useful tips section</a>
Note: Always add a forward slash to subfolders. If you write the link like this: href="https://www.oldtoolbag.com/html" will generate two HTTP requests to the server. This is because the server adds a forward slash to this address and then creates a new request, like this: href="https://www.oldtoolbag.com/html/".
Image links This example demonstrates how to use image links.
Link to a specified position on the current page This example demonstrates how to use bookmarks
Break out of the frame This example demonstrates how to break out of the frame, assuming your page is fixed within a frame.
Create an Email Link This example demonstrates how to link to an email. (This example will only work after the email client program is installed.)
Create an Email Link 2 This example demonstrates a more complex email link.
Tag | Description |
<a> | Define a Hyperlink |