Open In App
Related Articles

What is the use of “#” symbol in link URL ?

Improve Article
Improve
Save Article
Save
Like Article
Like

Many of us may have observed the pound(#) sign in the URL while inspecting some web sites. It is not a simple regular character but has a special function. So first of all, it is called a named anchor or sometimes as a fragment. Named anchor or fragment is used to link to the part of the same web –page. We generally link one page to the other, but what if we have to link to some heading which is on the same web-page? Then, named anchor (#) comes into play.

Syntax: It will just point to the top of the same page because that anchor tag is not given any link.

<a href="#">Click me</a>

Example: For example, you have a very long web page with several headings to navigate into those heading directly this will be helpful. Then for pointing the user to that specific heading with the link, the link must include. So, basically to point the user to some specific heading we use the pound sign with the name of that heading in the anchor tag. When used empty with no other dub heading, the same link points to the top of the same page.

Note: Blank # sign will bring you nowhere, cause it is not linked to any id attribute.

  • Program:




    <!DOCTYPE html>
    <html>
      
    <head>
        <title>link has a pound “#” sign</title>
        <style>
              
            h1 {
                color: green;
            }
              
            li {
                font-size: 16px;
                color: blue;
            }
        </style>
    </head>
      
    <body>
        <h1>GeeksforGeeks</h1>
        <b>A Computer Science Portal for Geeks</b>
        <ul>
            <li><a href="#learn">Learn</a></li>
            <li><a href="#contribute">Contribute</a></li>
            <li><a href="#explore">Explore</a></li>
        </ul>
        <div id="learn">
            <h4>Learn</h4>
            <p>
             A Computer Science portal for geeks. 
             It contains well written, well thought 
             and well explained computer science and 
             programming articles, quizzes and many more.
            </p>
        </div>
        <div id="contribute">
            <h4>Contribute</h4>
            <p>
             A Computer Science portal for geeks. 
             It contains well written, well thought 
             and well explained computer science and 
             programming articles, quizzes and many more.
            </p>
        </div>
        <div id="explore">
            <h4>Explore</h4>
            <p>
             A Computer Science portal for geeks. 
             It contains well written, well thought 
             and well explained computer science and 
             programming articles, quizzes and many more.
            </p>
        </div>
    </body>
      
    </html>

    
    

  • Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 27 Apr, 2020
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials