Home  >  Article  >  Web Front-end  >  What does href mean in html?

What does href mean in html?

清浅
清浅Original
2019-04-29 15:15:5254156browse

The href in HTML refers to a hypertext reference. Its value is the relative or absolute URL of any valid document, including identifiers or js code snippets. It is generally used in a tags to specify hypertext. Link jump target url.

Everyone is familiar with the a tag. Its most important function is to implement hyperlinks and anchors, and href is an important attribute in the a tag. Next, we will introduce href in detail in the article. What does it mean? It has certain reference value. I hope it will be helpful to everyone.

What does href mean in html?

[Recommended course: HTML tutorial]

href attribute

href refers to a hypertext reference, and its value can be a relative or absolute URL to any valid document, including fragment identifiers and JavaScript code snippets.

The href attribute in the a tag is used to specify the URL of the hyperlink target. If the href in an 3499910bf9dac5ae3c52d5ede7383485 tag is not specified as a link, then the 3499910bf9dac5ae3c52d5ede7383485 tag is not a link.

Syntax:

<a href="URL">

URL represents the URL of the hyperlink, which has the following three values:

Absolute URL: refers to the link address pointing to another A site, for example: href="http://www.php.cn/"

Relative URL: pointing to a file within the site, for example: href="/course/list/1.html"

Anchor URL: points to the anchor in the page, for example: href="#top"

Common usage of href:

(1 ) href="#" The href="#" in a tag means going back to the top. If scrolling is required in the current page, use this method You can go directly back to the top

<span style="font-size:14px;"><a href="#">回到最顶端</a></span>

(2)href="javascript:void(0);" Usage

This is the most commonly used method on the website, complete code As follows. The onclick method is responsible for executing the js function, and void is an operator. void(0) returns undefined to indicate that the address will not jump

<a href="javascript:void(0);" onclick="js_method()">

(3) a href="javascript:;" Usage

This method is similar to the above method. An empty js code is executed in this method.

<a href="javascript:;" onclick="js_method()">

Summary: The above is the entire content of this article. ,I hope to be helpful.

The above is the detailed content of What does href mean in html?. 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