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

MySQL login and exit command format

The command format for mysql login is: mysql -h [...

VUE+Express+MongoDB front-end and back-end separation to realize a note wall

I plan to realize a series of sticky note walls. ...

How to implement vertical text alignment with CSS (Summary)

The default arrangement of text in HTML is horizo...

How to use Node.js to determine whether a png image has transparent pixels

background PNG images take up more storage space ...

Detailed explanation of the interaction between React Native and IOS

Table of contents Prerequisites RN passes value t...

Basic syntax of MySQL index

An index is a sorted data structure! The fields t...

How to execute PHP scheduled tasks in CentOS7

Preface This article mainly introduces the releva...

Some data processing methods that may be commonly used in JS

Table of contents DOM processing Arrays method Su...

CSS3 Tab animation example background switching dynamic effect

CSS 3 animation example - dynamic effect of Tab b...

CSS and JS to achieve romantic meteor shower animation

1. Rendering 2. Source code HTML < body > &...

jQuery implements dynamic tag event

This article shares the specific code of jQuery t...

Implementation of multi-environment configuration (.env) of vue project

Table of contents What is multi-environment confi...

How to use the Marquee tag in XHTML code

In the forum, I saw netizen jeanjean20 mentioned h...