Baidu"/> Baidu">

Home  >  Article  >  Web Front-end  >  html jump to new page

html jump to new page

PHPz
PHPzOriginal
2023-05-27 19:30:072981browse

HTML is a markup language used to build web pages. One of the most common functions is the link function, which is used to allow users to jump to another page after clicking. This article will introduce how to use the link function in HTML and jump to a new page.

1. Use the tag to create a link

In HTML, we can use the tag to create a link. For example, the following code will create a link to a Baidu web page:

<a href="https://www.baidu.com">百度一下,你就知道</a>

Among them, the href attribute specifies the target URL of the link, and the text within the label is the display text of the link.

2. Open the link in the current page

By default, the link will be opened in the current page. For example, clicking the link above will open the Baidu web page in the current page. If you want the link to open in a new page, you can use the target attribute.

3. Open the link in a new page

To open the link in a new page, you need to specify the target attribute as "_blank", as shown below:

<a href="https://www.baidu.com" target="_blank">百度一下,你就知道</a>

In this way, clicking the link will open the Baidu web page in a new browser tab.

4. Link to local files

In HTML, we can also use the link function to link to local files, for example:

<a href="images/cat.jpg">查看猫咪照片</a>

Here, we point the link to An image file named "cat.jpg". When the user clicks the link, the image file will be opened in the current page.

5. Link to bookmark

In addition to linking to external web pages or local files, we can also use the link function to link to a certain location within the page, the so-called bookmark (Bookmark). To create a bookmark, you need to add "# bookmark" after the target address of the link, for example:

<a href="#overview">查看概览</a>

<h2 id="overview">概览</h2>

Here, we first added an id attribute to the c1a436a314ed609750bd7c7d319db4da tag, named " overview", which becomes a bookmark. Then, add "#bookmark" to the target address of the link to point to the bookmark. When the user clicks on the link, it will automatically scroll to the bookmark location on the page.

Summary

Using the link function of HTML allows us to easily jump to other pages, open local files, or jump to a specific location within the page. Use the tag to create a link, and specify the target and opening method of the link through the href and target attributes. At the same time, we can also use bookmarks to point to specific locations within the page.

The above is the detailed content of html jump to new page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn