What does href=# mean in a link?

What does href=# mean in a link?
Links to the current page.
-------------------
Common usages are as follows :
<a href="#" onclick="window.close()">Close</a>
Setting href="#" to link to the current page is actually meaningless, and the page will not refresh. The key is the onclick that follows. When you click "Close", the window.close() code will be executed.

You might ask why not just write <a onclick="window.close()">Close</a>
If written like this, the two words "close" will not be processed as a hyperlink and the effect will look worse. You can try it yourself. When making a web page, the parameters in the HTML language are used to specify the link url. #### is the link to this page, and href="address" is the link to the address. The default link is this page, and no new window will pop up. For an empty link, if # is removed, the mouse hand cursor will not be displayed. In layman's terms, it is a fake link pointing to this page. You can also add the anchor ID after #. This is actually another way to use a bookmark.

Create a bookmark <br />Syntax: <a name="Bookmark name">Text</a>
Bookmarks linking to the same page (use)
Syntax: <a href="#bookmark name">link text</a>
The syntax of a bookmark linking to a different page is: <a href="link file address#bookmark name">link text</a> (note the quotation marks and #)

Under normal circumstances, if you click on the link: <a href="#Bookmark name">Link text</a>, the cursor will automatically jump to the position of: <a name="Bookmark name">Text</a> on this page.

But if you write: <a href="#">link text</a> without writing the bookmark name, it will actually not jump to anything. Generally, href="#" will only be reached when <a onclick="">
Just treat it as an empty link. It will show the link effect (such as the mouse turns into a small hand), but there is no page jump.

<<:  The past two years with user experience

>>:  Use Docker to create a distributed lnmp image

Recommend

How to remove the dividing line of a web page table

<br />How to remove the dividing lines of a ...

Native JavaScript to achieve skinning

The specific code for implementing skinning with ...

Problems encountered when updating the auto-increment primary key id in Mysql

Table of contents Why update the auto-increment i...

Floating menu, can achieve up and down scrolling effect

The code can be further streamlined, but due to t...

vmware virtual machine ubuntu18.04 installation tutorial

Installation Steps 1. Create a virtual machine 2....

Modify the jvm encoding problem when Tomcat is running

question: Recently, garbled data appeared when de...

How to implement n-grid layout in CSS

Common application scenarios The interfaces of cu...

Html easily implements rounded rectangle

Question: How to achieve a rounded rectangle usin...

Solution to the problem of var in for loop

Preface var is a way to declare variables in ES5....

Detailed tutorial for upgrading zabbix monitoring 4.4 to 5.0

1. Zabbix backup [root@iZ2zeapnvuohe8p14289u6Z /]...

Springboot+VUE to realize login and registration

This article example shares the specific code of ...

js realizes a gradually increasing digital animation

Table of contents background Achieve a similar ef...

About WSL configuration and modification issues in Docker

https://docs.microsoft.com/en-us/windows/wsl/wsl-...

Summary of MySQL basic common commands

Table of contents MySQL basic common commands 1. ...