Suppose we have a web page that is opened on a tab of a browser window. Now we want to add a link on that web page so that after clicking the link, the tab that contains the web page will be close. How to do that? Well, here we are going to see that.
Below is the method that closes the current window tab:
Now suppose you want to create a link that will close the current tab when it will be clicked. To do that lets first create our HTML link:
<a href="#" id="close-window">Close this window tab</a>
Below is the complete example code:
Save the above code as an HTML file. After saving it, if you open it on with your browser, you will see a link with the text “Close this window tab“. After clicking this link you will see your browser tab immediately close.